Position of navigation bar for modal view - iOS7

前端 未结 8 2213
南笙
南笙 2020-11-29 18:08

In a navigation controller, you automatically get the correct colour and position of a navigation bar as expected.

like this

8条回答
  •  情深已故
    2020-11-29 19:12

    The best way to overcome this in iOS 7 is by conforming to the new UIBarPositioningDelegate protocol.

    You connect the delegate of your NavigationBar to your view controller (set your view controller as the delegate for the navigation bar either through storyboard or through code) and conform to that protocol and by implementing the method

    -(UIBarPosition)positionForBar:(id)bar { return UIBarPositionTopAttached; }

    You can remove the top gap in the view controller. You need to place the bar 20 points below the top edge

提交回复
热议问题