Hello I'm using this code to set the shadow image of my navbar:
if ([self.navigationController.navigationBar respondsToSelector:@selector(shadowImage)]) {
[[UINavigationBar appearance] setShadowImage:[UIImage imageNamed:@"nav-bar-shadow"]];
[[UIToolbar appearance] setShadowImage:[UIImage imageNamed:@"tool-bar-shadow"] forToolbarPosition:UIToolbarPositionAny];
}
However it seems this is iOS 6 only (though I can't say for sure - I can't find documentation about this anywhere). It doesn't work on iOS 5.
Is there some kind of alternative - globally setting an image under the navbar? I thought of custom UIView, but how to do this globally?
You can:
viewController.view
[[UIApplication sharedApplication] keyWindow]
, which will add the image globally on your window. However, it can get a little bit ugly e.g. when displaying a modal view controller.UINavigationBar
, do some magic with subviews in there and then initialize your navigationController via [[UINavigationController alloc] initWithNavigationBarClass:[YourNavBarSubclass class] toolbarClass:[UIToolbar class]]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With