How to set status bar color same as to Navigation bar color in iOs 7 using Xcode 4.2
In iOS6 you can't change the image or the color of the status bar apart from this 2 styles:
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackOpaque];
[[UIApplication sharedApplication]setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
Navigation bar in iOS 6 look like bar in iOS 7
Instead of putting code into every view controller that you need to customize, I would recommend doing this for the entire application by putting something like this in your application:didFinishLaunchingWithOptions:
method in the App Delegate
// Nav bar
[[UINavigationBar appearance] setBackgroundImage:[[UIImage imageNamed:@"navBar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 5, 10, 5)] forBarMetrics:UIBarMetricsDefault];
// Back buttons
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:@"backNavButton.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
// Toolbar
[[UIToolbar appearance] setBackgroundImage:[[UIImage imageNamed:@"toolbar.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 5, 10, 5)] forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
Change navigation bar tint color iOS 7.
you can add bellow code in appdelegate.m
if your app is navigation based
// for background color
[nav.navigationBar setBarTintColor:[UIColor blueColor]];
// for change navigation title and button color
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont fontWithName:@"FontNAme" size:20], NSFontAttributeName, nil]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
Unable to change navigation bar color
There are two ways to do this. You can either modify the appearance proxy that you have set up in the AppDelegate for the whole app, or you can modify the individual navigationbar for the particular screen.
When you dismiss the view - you need to reset the barTintColor in the viewWillDisappear.
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// Set to new colour for whole app
UINavigationBar.appearance().barTintColor = UIColor.blueColor()
// Or, Set to new colour for just this navigation bar
self.navigationController?.navigationBar.barTintColor = UIColor.blueColor()
}
override func viewWillDisappear(animated: Bool) {
super.viewWillDisappear(animated)
//Revert to old colour, whole app
UINavigationBar.appearance().barTintColor = UIColor.redColor()
//Revert to old colour, just this navigation bar
self.navigationController?.navigationBar.barTintColor = UIColor.redColor()
}
Related Topics
Xcode/Simulator: How to Run Older iOS Version
Cabasicanimation Does Not Animate Correctly When I Update Model Layer
How to Fetch User's Email Using Facebook
Missing Compliance Status in Testflight
Uitableviewcell Separator Disappearing in iOS7
Swift 3.0, Alamofire 4.0 Extra Argument 'Method' in Call
How to Identify Ekevent Uniquely with Sync Across the Devices
Cordova: Start Specific iOS Emulator Image
How to Deselect a Selected Uitableview Cell
How to Make a Call Which Begin with * in Iphone
How to Split a Numeric String Using Multiple Separators in a Swift Closure
Disable the Interactive Dismissal of Presented View Controller
Uiimageview Aspect Fit and Center
I Want to Create Aes 128 Using Cfb Encryption with No Padding in Objective C
Alamofire: Sending JSON as Request Parameter