[英]iOS7 status bar issue that I can't figure out
我在iOS7中有2个我不知道的问题。
第一个问题是TableView行位于状态栏下方,如何禁用它,或使表格视图的节标题始终位于状态栏下方?
我遇到的第二个问题是导航控制器上的状态栏似乎是黑色且背景为黑色,我不知道如何解决,视图控制器的背景为白色,但是状态栏却提示为黑色,但我没有知道为什么。
更新:
仍然没有答案。
我认为您需要执行以下代码。
您将必须检查ios7的条件。
您将需要使用这两个委托方法进行tableview。
检查下面的代码。
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
int versionValue=[currSysVer intValue];
if(versionValue>=7)
{
return 60;
}
return 0;
}
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 60)];
[headerView setBackgroundColor:[UIColor clearColor]];
return headerView;
}
希望这对您有所帮助。
回答第二个问题!
输入您的didFinishLaunchingWithOptions:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[self customizeios7];
} else {
[self customizeios6];
}
并使这两个空隙:
-(void)customizeios6 {
UIImage *navBackgroundImage = [UIImage imageNamed:@"navigationbar-ios6"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
}
-(void)customizeios7 {
// SET STATUSBAR TEXT WHITE
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
// SET NAVIGATION IMAGE
UIImage *navBackgroundImage = [UIImage imageNamed:@"navigationbar-ios7"];
[[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault];
}
UINavigationBar的图像尺寸:
对于iOS 6:
640px / 88px
对于iOS 7:
640像素/ 128像素
使用这些代码行
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self prefersStatusBarHidden];
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
和
- (BOOL)prefersStatusBarHidden
{
return YES;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.