Position MBProgressHUD at the Bottom/Top of the screen

前端 未结 5 1115
醉话见心
醉话见心 2020-12-17 21:28

Is there a way to make the MBProgressHUD show at the bottom or top of the screen?

I have tried setting the frame using [hud setFrame:....];, initW

相关标签:
5条回答
  • 2020-12-17 21:54

    for Swift 4 , changed hud.offset.x and hud.offset.y

    let hud = MBProgressHUD.showAdded(to: self.view, animated: true)
    hud.mode = MBProgressHUDMode.annularDeterminate
    hud.offset.y = 10
    hud.offset.x = 10
    
    0 讨论(0)
  • 2020-12-17 21:54

    No its not posible to change the position of MBProgressHUD to top or bottom.refer this link

    0 讨论(0)
  • 2020-12-17 21:56

    Yes, we can change MBProgressHUD view location from center to the bottom or top.

    Just add the yOffset property of the MBProgressHUD and you will get the exact location that you want.

    Use :

    MBProgressHUD *Hud = [[MBProgressHUD alloc] init];
    hud.yOffset = 250.0; //For bottom location.
    
    0 讨论(0)
  • 2020-12-17 22:03

    We can change position of MBProgressHUD via change in yOffset and xOffset. Below line of code is for place MBProgressHUD at bottom.

    let hud = MBProgressHUD.showAdded(to: view, animated: true)
    hud?.mode = .text
    hud?.labelText = json!["message"] as! String
    hud?.yOffset = Float(view.frame.size.height*2/5);
    hud?.removeFromSuperViewOnHide = true
    hud?.margin = 10.0
    hud?.hide(true, afterDelay: 2)
    
    0 讨论(0)
  • 2020-12-17 22:15

    I had the same trouble with a SVProgressHUD turns out I just had to add a new method

    + (void)setOffsetFromCenter:(UIOffset)offset {
    [self sharedView].offsetFromCenter = offset;
    }
    

    and call it when I showed the HUD

    [SVProgressHUD setOffsetFromCenter:UIOffsetMake(0, 120)];
    

    Mine just had to go a bit lower than mid-screen. Try it out, its a SingleTon so it's easier to call show and remove.

    0 讨论(0)
提交回复
热议问题