Adjusting UIBarItemButton for UIToolbar in iOS 7

In iOS 7 the Navigation Bar extends up to the status bar. If you are using a background image for Navigation Bar then it should be 64 points in height instead of the classic 44 points. The first 20 points belongs to the status bar and the last 44 points belong to the Navigation Bar. 

You can also set the tint color of the navigation bar background by using the barTintColor property.  

[self.navigationController.navigationBar setBarTintColor:[UIColor blueColor]];

The result is the following: 

Screen Shot 2013-11-11 at 12.26.24 PM.png

Everything looks as you expected. Now, let's see how this will look like when you are using a Toolbar instead of the navigation bar. The screenshot below shows how you will adjust the toolbar using Storyboards. 

Screen Shot 2013-11-11 at 12.30.02 PM.png

The result is shown below:  

Screen Shot 2013-11-11 at 12.31.57 PM.png

The bar item buttons are too close to the carrier label as well as the battery label. In other words they are not adjusted properly. The main reason for this issue is that the toolbar is positioned at origin (0,0) and it is only 44 points heigh. In order to accommodate for the status bar the toolbar needs to be placed at origin (0,20) as shown below:  

Screen Shot 2013-11-11 at 12.36.28 PM.png

Run the application and you will notice the difference: 

Screen Shot 2013-11-11 at 12.37.55 PM.png

Well, that kind of solves the problem but now out toolbar does not extends up to the status bar which looks weird. In order to fix this problem you will need to return UIBarPositionTopAttached for the barForPosition property of the UIBarPositioningDelegate. The UIToolbar already conforms to the UIBarPositioningDelegate delegate and returns UIBarPositionBottom. 

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

Now if you run the application you will notice that the toolbar extends all the way to the status bar.  

Screen Shot 2013-11-11 at 12.50.25 PM.png