Status bar and navigation bar appear over my view's bounds in iOS 7

后端 未结 20 2171
既然无缘
既然无缘 2020-11-22 07:09

I recently downloaded Xcode 5 DP to test my apps in iOS 7. The first thing I noticed and confirmed is that my view\'s bounds is not always resized to account for the status

20条回答
  •  情书的邮戳
    2020-11-22 08:04

    If you want the view to have the translucent nav bar (which is kind of nice) you have to setup a contentInset or similar.

    Here is how I do it:

    // Check if we are running on ios7
    if([[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."][0] intValue] >= 7) {
          CGRect statusBarViewRect = [[UIApplication sharedApplication] statusBarFrame];
          float heightPadding = statusBarViewRect.size.height+self.navigationController.navigationBar.frame.size.height;
    
          myContentView.contentInset = UIEdgeInsetsMake(heightPadding, 0.0, 0.0, 0.0);
    }
    

提交回复
热议问题