Is there any way to make the UINavigationBar
, targeted for iOS 7, a solid color with no translucency? I have tried setting the backgroundColor, the barTintColor, opaque, transparent/translucent, etc... and nothing works.
Anyone know how to do this?
Here are some chunks of code I have been using. Notice the properties I have set on the navigationBar
. None of them, in any order or combination have worked.
@property (strong, nonatomic) UITabBarController *tabBarController; testViewController = [[TestViewController alloc] init]; anotherViewController = [[AnotherViewController alloc] init]; navigationController = [[UINavigationController alloc] initWithRootViewController:testViewController]; navigationController.navigationBar.barTintColor = [UIColor darkGrayColor; navigationController.navigationBar.barStyle = UIBarStyleBlack; navigationController.navigationBar.translucent = YES; navigationController.navigationBar.opaque = YES; NSArray *tabBarViewControllers = [NSArray arrayWithObjects: navigationController, anotherViewController, nil]; self.tabBarController.viewControllers = tabBarViewControllers;
You need to do three things to make a navigation bar transparent. Set background image to non-nil empty image ( UIImage() ). Set shadow image to non-nil empty image ( UIImage() ). Set isTranslucent to true .
Start with Navigation ControllerCreate a single view application in Xcode. Add two view controller into your storyboard. Create two different swift files for those view controllers and set identifiers for them. Take a button in each view controller, set constrain for them and customize as you want.
Your code lists navigationController.navigationBar.translucent = YES;
Set it to NO.
To make it totally opaque u can just change the style of the navigation bar from the property section itself!
This is how it looks like when u make it black
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