【发布时间】:2018-06-06 16:49:23
【问题描述】:
我想要一个带有白色文本的黑色状态栏。 我使用的一般方法是使用浅色状态栏来创建自定义黑色视图并将其添加到视图控制器的顶部
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, statusBarHeight)];
view.backgroundColor = [UIColor blackColor];
[self.view addSubview:view];
如果视图控制器嵌入在导航控制器中,我会这样做
CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -statusBarHeight, [UIScreen mainScreen].bounds.size.width, statusBarHeight)];
view.backgroundColor = [UIColor blackColor];
[self.navigationController.navigationBar addSubview:view];
然而这似乎不是一个非常优雅的解决方案,也许有更好的方法?
【问题讨论】:
标签: ios objective-c iphone uinavigationcontroller