I solved this problem in Swift 3
var hud = MBProgressHUD()
hud.backgroundColor = UIColor.clear
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)
source
share