将MBProgressHUD置于屏幕的底部/顶部 [英] Position MBProgressHUD at the Bottom/Top of the screen

查看:234
本文介绍了将MBProgressHUD置于屏幕的底部/顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让MBProgressHUD显示在屏幕的底部或顶部?

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

我尝试使用设置框架[ hud setFrame:....]; initWithFrame ,并设置 center 属性的。这些都没有奏效。尝试这些方法后,我做了帧的NSLog()。值已经改变,但是hud仍然显示在屏幕的中心。

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.

需要注意的是,使用UIWindow显示hud:

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";

这是因为hud是由后台执行块显示的,因此hud可以显示在任何查看当前显示。

Did this because the hud is displayed by a background execution block, thus the hud could be displayed on any view currently in display.

推荐答案

是的,我们可以更改 MBProgressHUD 查看从中心到底部或顶部的位置。

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

只需添加 yOffset 属性MBProgressHUD ,您将获得所需的确切位置。

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

使用:

MBProgressHUD *Hud = [[MBProgressHUD alloc] init];
hud.yOffset = 250.0; //For bottom location.

这篇关于将MBProgressHUD置于屏幕的底部/顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆