Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing shadow (hairline) on iOS7 UIToolbar

In iOS7, UIToolbar does not appear to have a little line (the shadow) on the top or bottom borders, which makes it difficult to distinguish from the rest of the app. How can I restore the shadow at the bottom of the toolbar when it is at the top of the screen?

EDIT: I should clarify that my toolbar is positioned at the top of the screen. After moving things around I realized that it IS drawing a shadow, but it's on the top, and therefore off-screen. What I want is for the shadow to appear at the bottom like a UINavigationBar.

like image 345
GoldenJoe Avatar asked Dec 18 '13 23:12

GoldenJoe


2 Answers

This is because, by default, toolbars are attached to bottom, so the shadow line appears at the top (if they are at the bottom). You need to set the delegate of the toolbar and implement the following UIBarPositioningDelegate method like so:

- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
{
    return UIBarPositionTop; //or UIBarPositionTopAttached
}
like image 104
Léo Natan Avatar answered Nov 08 '22 06:11

Léo Natan


I just ran into a case where a view was positioned between a top and bottom toolbar and configured to auto-resize to fill the space. However, it was layered above the bottom toolbar and the auto-resize made it cover the bottom toolbar's top shadow. The solution was to adjust the layering in Interface Builder so the toolbars were layered above the other views.

like image 38
arlomedia Avatar answered Nov 08 '22 05:11

arlomedia