I would like an entirely transparent UIToolbar
and/or UINavigationBar
. I have tried the various incantations suggested for pre- and post-iOS 5 but none seem to work any more.
How might this be accomplished in iOS 7?
UIToolbar
self.toolbar.setBackgroundImage(UIImage(),
forToolbarPosition: .any,
barMetrics: .default)
self.toolbar.setShadowImage(UIImage(), forToolbarPosition: .any)
UINavigationBar
self.navigationBar.setBackgroundImage(UIImage(), for: .default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.isTranslucent = true
UIToolbar
self.toolbar.setBackgroundImage(UIImage(),
forToolbarPosition: UIBarPosition.Any,
barMetrics: UIBarMetrics.Default)
self.toolbar.setShadowImage(UIImage(),
forToolbarPosition: UIBarPosition.Any)
UINavigationBar
self.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
self.navigationBar.shadowImage = UIImage()
self.navigationBar.translucent = true
UIToolbar
[self.toolbar setBackgroundImage:[UIImage new]
forToolbarPosition:UIBarPositionAny
barMetrics:UIBarMetricsDefault];
[self.toolbar setShadowImage:[UIImage new]
forToolbarPosition:UIBarPositionAny];
UINavigationBar
[self.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;
Setting translucent
to YES
on the navigation bar does the trick, due to a behavior discussed in the UINavigationBar
documentation. I'll report here the relevant fragment:
If you set this property to
YES
on a navigation bar with an opaque custom background image, the navigation bar will apply a system opacity less than 1.0 to the image.