Search code examples
iosiphoneipadios7uitoolbar

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.


Solution

  • 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
    }