jdg / MBProgressHUD

MBProgressHUD + Customizations
http://www.bukovinski.com/
MIT License
16.01k stars 3.56k forks source link

the graceTime don't work #402

Closed wulongwang closed 6 years ago

wulongwang commented 8 years ago

[MBProgressHUD appearance].contentColor = [UIColor greenColor]; MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES]; hud.graceTime = 5.0f; hud.completionBlock = ^{ NSLog(@"------------completionBlock"); }; when you create MBProgressHUD instance and show ,the graceTime always zero,because you set graceTime hud already show and don't change the graceTime value

matej commented 8 years ago

The graceTime needs to be set before the hud is shown. You thus can't use showHUDAddedTo:animated:, but instead need to alloc / init the hud, configure the grace time and than call show manually.

I'll improve the documentation for this.

NikKovIos commented 7 years ago

Could you provide an example code please. I do:

let hud = MBProgressHUD(view: view)
hud.graceTime = 2
hud.removeFromSuperViewOnHide = true
hud.animationType = .zoom
hud.backgroundView.style = .blur
hud.bezelView.color = UIColor.white
hud.bezelView.style = .blur
hud.show(animated: true)

but it doesn't work.

matej commented 7 years ago

See https://github.com/jdg/MBProgressHUD/blob/master/Demo/HudTests/HudTests.m#L268

matej commented 6 years ago

Addressed in d416673

teejayhh commented 3 years ago

@NikKovIos I know is a super old thread but just ran into the same problem.

add view.addSubview(hud) to your code and it should work