Happy belated iOS7 day to all the devs out there. Not that the rest of the interwebs paid any attention to the Apple Dev NDA, but now that I’m legally allowed to talk about all things iOS7 related, here’s a code nugget for anyone using modal view controllers with a stand-alone
If you’re following the new iOS7 design paradigm, you’ll want your nav bar to seamlessly extend to the top edge and blend in beneath the status bar. If you’re using a navigation controller this is automatically done for you. However, if you’re building your own custom modal view controller AND add a standalone UINavigationBar to your storyboard, this is what you’ll get:
You can see that the nav bar sticks out like a sore thumb. So to fix this, here’s what you’ll need to do:
1. Make sure (in your storyboard scene) that your UINavigationBar is set to ‘Translucent’
2. Set the delegate property of your UINavigationBar to your View Controller (or some class that implements the UINavigationBarDelegate protocol).
3. In your delegate class (e.g. your View Controller) implement the following code:
- (UIBarPosition)positionForBar:(id )bar
And now you should see something like this:
Hope this helps!
“Delete all your comments. If it was hard to write it should be hard to read”