Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
753 views
in Technique[技术] by (71.8m points)

ios - Position MBProgressHUD at the Bottom/Top of the screen

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...