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

后端 未结 20 1608
既然无缘
既然无缘 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 07:58

    The simplest trick is to open the NIB file and do these two simple steps:

    1. Just toggle that and set it to the one you prefer:

    Enter image description here

    1. Select those UIView's/UIIMageView's/... that you want to be moved down. In my case only the logo was overlapped an I've set the delta to +15; (OR -15 if you chose iOS 7 in step 1)

    Enter image description here

    And the result:

    Before After

    0 讨论(0)
  • 2020-11-22 07:59

    make a constraints to Top Layout like this

    0 讨论(0)
  • 2020-11-22 08:02

    You can achieve this by implementing a new property called edgesForExtendedLayout in iOS7 SDK. Please add the following code to achieve this,

    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
            self.edgesForExtendedLayout = UIRectEdgeNone;
    

    You need to add the above in your -(void)viewDidLoad method.

    iOS 7 brings several changes to how you layout and customize the appearance of your UI. The changes in view-controller layout, tint color, and font affect all the UIKit objects in your app. In addition, enhancements to gesture recognizer APIs give you finer grained control over gesture interactions.

    Using View Controllers

    In iOS 7, view controllers use full-screen layout. At the same time, iOS 7 gives you more granular control over the way a view controller lays out its views. In particular, the concept of full-screen layout has been refined to let a view controller specify the layout of each edge of its view.

    The wantsFullScreenLayout view controller property is deprecated in iOS 7. If you currently specify wantsFullScreenLayout = NO, the view controller may display its content at an unexpected screen location when it runs in iOS 7.

    To adjust how a view controller lays out its views, UIViewController provides the following properties:

    • edgesForExtendedLayout

    The edgesForExtendedLayout property uses the UIRectEdge type, which specifies each of a rectangle’s four edges, in addition to specifying none and all. Use edgesForExtendedLayout to specify which edges of a view should be extended, regardless of bar translucency. By default, the value of this property is UIRectEdgeAll.

    • extendedLayoutIncludesOpaqueBars

    If your design uses opaque bars, refine edgesForExtendedLayout by also setting the extendedLayoutIncludesOpaqueBars property to NO. (The default value of extendedLayoutIncludesOpaqueBars is NO.)

    • automaticallyAdjustsScrollViewInsets

    If you don’t want a scroll view’s content insets to be automatically adjusted, set automaticallyAdjustsScrollViewInsets to NO. (The default value of automaticallyAdjustsScrollViewInsets is YES.)

    • topLayoutGuide, bottomLayoutGuide

    The topLayoutGuide and bottomLayoutGuide properties indicate the location of the top or bottom bar edges in a view controller’s view. If bars should overlap the top or bottom of a view, you can use Interface Builder to position the view relative to the bar by creating constraints to the bottom of topLayoutGuide or to the top of bottomLayoutGuide. (If no bars should overlap the view, the bottom of topLayoutGuide is the same as the top of the view and the top of bottomLayoutGuide is the same as the bottom of the view.) Both properties are lazily created when requested.

    Please refer, apple doc

    0 讨论(0)
  • Steps For Hide the status bar in iOS 7:

    1.Go to your application info.plist file.

    2.And Set, View controller-based status bar appearance : Boolean NO

    Hope i solved the status bar issue.....

    0 讨论(0)
  • 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);
    }
    
    0 讨论(0)
  • 2020-11-22 08:04

    Swift 3

    override func viewWillAppear(_ animated: Bool) {
        self.edgesForExtendedLayout = []
    }
    
    0 讨论(0)
提交回复
热议问题