【发布时间】:2012-05-16 05:18:58
【问题描述】:
我想在 iPhone 底部显示一个状态栏,就像 Gmail 帐户中的状态栏一样,表明它正在检查邮件。我在这个线程中尝试了以下解决方案 Adding view on StatusBar in iPhone
但是状态栏没有出现,然后我使用相同的代码没有任何修改将其显示在默认状态栏的顶部,它也没有出现。
我也尝试过使用MTStatusBarOverlay 的另一种解决方案,当我尝试将其框架更改为底部时,我在屏幕中间看到了一个黑色矩形
有什么帮助吗?
这里是代码
// new class i have created
@interface BottomStatusBarOverlay : UIWindow
@end
@implementation BottomStatusBarOverlay
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
// Place the window on the correct level and position
self.windowLevel = UIWindowLevelStatusBar+1.0f;
self.frame = [[UIApplication sharedApplication] statusBarFrame];
self.alpha = 1;
self.hidden = NO;
// Create an image view with an image to make it look like a status bar.
UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:self.frame];
backgroundImageView.image = [[UIImage imageNamed:@"statusBarBackgroundGrey.png"] stretchableImageWithLeftCapWidth:2.0f topCapHeight:0.0f];
[self addSubview:backgroundImageView];
}
return self;
}
@end
// usage in my view controller in a button action
@implementation MainViewController
-(IBAction)showBottomStatusbar:(id)sender {
BottomStatusBarOverlay *bottomStatusBarOverlay = [[BottomStatusBarOverlay alloc] init];
bottomStatusBarOverlay.hidden = NO;
}
【问题讨论】:
-
请发布一些代码,以便我们查看可能出现的问题。
-
是的,添加您使用的代码,使其不显示。
-
将状态栏移动到设备底部违反了 Apple 的人机界面指南。最好使用不同的 UI 元素来显示内容。考虑看看 Mail 应用程序是如何做到的。
-
我没有将状态栏移到底部,我正在使用一个新的状态栏并将其放在屏幕底部,默认的状态栏是相同的,所以我使用了从UIWindow 但它没有出现在顶部和底部的问题
标签: iphone ios uikit uiapplication