Does MBProgressHud View setup not work in Swift 3 and not display?

I am using the following code but not showing hud progress, so please help with this. A simple hud will show fine, but tune without showing

let loadingHUD = MBProgressHUD() 

loadingHUD.mode = MBProgressHUDModeCustomView
loadingHUD.labelText = nil
loadingHUD.detailsLabelText = nil
let customView = UIView.init(frame: CGRect(x: 0, y: 0, width: 80, height: 80))

let gifmanager = SwiftyGifManager(memoryLimit:20)
let gif = UIImage(gifName: "miniballs1.gif")
let imageview = UIImageView(gifImage: gif, manager: gifmanager)
imageview.frame = CGRect(x: 0 , y: 0, width: customView.frame.width, height: customView.frame.height)
customView.addSubview(imageview)
customView.bringSubview(toFront: imageview)

loadingHUD.customView = customView
loadingHUD.customView.bringSubview(toFront: customView)
loadingHUD.show(true)
+4
source share
3 answers

Try using this ACProgressHud-Swift library

In the xib file, any kind of make then configures and uses it.

To display

ACProgressHUD.shared.showHUD(withStatus: "Your Message Name")

To hide

ACProgressHUD.shared.hideHUD()
+2
source

I solved this problem in Swift 3

   var hud = MBProgressHUD()


 hud.backgroundColor = UIColor.clear


// Set an image view with a checkmark.
let gifmanager = SwiftyGifManager(memoryLimit:20)
let gif = UIImage(gifName: "eclipse.gif")
let imageview = UIImageView(gifImage: gif, manager: gifmanager)
hud.labelText = NSLocalizedString(string, comment: "")
hud.labelColor = UIColor.red

imageview.frame = CGRect(x: 0 , y: 0, width: 80 , height: 80)

let views = UIView.init(frame: CGRect(x: 0 , y: 0, width: 80 , height: 80))
views.backgroundColor = UIColor.black
views.addSubview(imageview)

hud.customView = views

hud.customView.backgroundColor = UIColor.clear
hud.dimBackground = true

    hud.show(true)
+4
source
import UIKit

class Loader:  NSObject {


class func setup()
{
    MBProgressHUD.setDefaultMaskType(.Black)
    MBProgressHUD.setBackgroundColor(UIColor(white: 0, alpha: 0.7))
    MBProgressHUD.setForegroundColor(UIColor(white: 1, alpha: 1))

}

class func Show(message:String = "loading..."){

    MBProgressHUD.showWithStatus(message)
    UIApplication.sharedApplication().networkActivityIndicatorVisible = true

}

class func Hide(){
    MBProgressHUD.dismiss()
    UIApplication.sharedApplication().networkActivityIndicatorVisible = false
}
}

MBProgressHUD Loader.Show()

0

Source: https://habr.com/ru/post/1679771/


All Articles