Changing UISearchBar Button Color

To change the UISearchBar button color, the simplest approach is to change the Tint color in it’s View section using storyboard.

However, it will also affect the insertion point color.

So if you want a white color button, the insertion point will disappear because is the same color as the search bar background…

To tackle this problem, we can configure the appearance of the search bar using its appearance proxy in the app delegate:

NSDictionary *attrDict = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
UIBarButtonItem *buttonItemProxy = [UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil];
[buttonItemProxy setTitleTextAttributes:attrDict forState:UIControlStateNormal];

This will only change the color of the button but not the insertion point.

Note that this approach will affect all search bars in your app.

Changing UISearchBar Button Color

Tab Bar Background Color and Button Tint Color

To change the background color of tab bar, we can change the tab bar setting in storyboard.

However, unlike navigation bar, we cannot setting the tab bar item’s tint color inside storyboard.

We have to add some code in the app delegate, inside application:didFinishLaunchingWithOptions:, add

[[UITabBar appearance] setTintColor:[UIColor yellowColor]];

Note that this is an application-wide setting, all tab bar items will tint to the specific color.

Tab Bar Background Color and Button Tint Color

Navigation Bar Background Color and Buttons Tint Color

To change the background color of navigation bar and the tint color of bar button items, no code is needed.

In the storyboard, click on the navigation bar of your navigation controller.

Set the Bar Tint for changing the background color. And Tint inside the View section.

Below shows how to set the background to blue and buttons to white.

Navigation Bar Background Color and Buttons Tint Color

Hide Status Bar

Starting from iOS 7, there are 2 ways to hide the status bar. One is to hide the status bar in all view controllers, while the other is controller specific.

  1. App-based setting

Set “View controller-based status bar appearance” in target’s info to NO.

then in the app delegate, inside application:didFinishLaunchingWithOptions:, add

[application setStatusBarStyle:UIStatusBarStyleLightContent];
  1. Controller-based setting

Set “View controller-based status bar appearance” to YES.

Inside viewDidLoad, add

[self setNeedsStatusBarAppearanceUpdate]

and then add the following function:

-(UIStatusBarStyle)preferredStatusBarStyle{ 
    return UIStatusBarStyleLightContent; 
}
Hide Status Bar