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:....];
, initWithFrame
, and setting thecenter
property of the hud. None of these worked. I did an NSLog() of the frames after trying these methods. The values had changed but the hud still displayed at the center of the screen.
A thing to note, the hud is displayed using a UIWindow:
UIWindow *window = [[[UIApplication sharedApplication] windows] lastObject];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:window animated:YES];
hud.mode = MBProgressHUDModeText;
hud.labelText = @"some text";
Did this because the hud is displayed by a background execution block, thus the hud could be displayed on any view currently in display.
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.