Issue 1: The status bar turns black when using uisearchdisplaycontroller Search
Solution: Refer to the reference 1 method to change the background of the navigation controller view to [Self.navigationController.view Setbackgroundcolor:[uicolor Whitecolor]]; or the color of the search bar
Issue 2: Solution to issue 1 may result in white font on iphone5s, resulting in unclear time on the status bar, power
Solution: Implement the two methods in the Uisearchdisplaydelegate, change the status bar font to black when searching, and then change the status bar font to white when the search is finished.
-(void delegate = self;} -(void ) Searchdisplaycontrollerwillbeginsearch: (Uisearchdisplaycontroller * ) controller{ [uiapplication sharedapplication].statusbarstyle = -(void ) Searchdisplaycontrollerdidendsearch: (Uisearchdisplaycontroller *< Span style= "color: #000000;" >) controller{ // [ UIApplication sharedapplication].statusbarstyle = uistatusbarstylelightcontent;}
Issue 2 Solution Optimization: Create a controller base class that implements the 3 methods of the problem 2 solution, and the other controller that uses the Uisearchdisplaycontroller search inherits the base class.
#import <uikit/uikit.h>//! The Uisearchdisplaycontroller controller can inherit the base class so that when searching, the font of the status bar turns black, and the font of the status bar changes back to white when the search is complete @interface Uisearchdisplaybaseviewcontroller:uiviewcontroller<uisearchdisplaydelegate> @end
#import "UISearchDisplayBaseViewController.h" @implementation uisearchdisplaybaseviewcontroller-(void) viewdidload { [super viewdidload]; Self.searchDisplayController.delegate = self;} -(void) Searchdisplaycontrollerwillbeginsearch: (Uisearchdisplaycontroller *) controller{ //The font of the status bar turns black [ UIApplication sharedapplication].statusbarstyle = Uistatusbarstyledefault;} -(void) Searchdisplaycontrollerdidendsearch: (Uisearchdisplaycontroller *) controller{ //The font of the status bar turns white [ UIApplication sharedapplication].statusbarstyle = uistatusbarstylelightcontent;} @end
Reference documents:
1.Uisearchdisplaycontroller the solution to the black bar problem at the top of the screen when you click Search http://blog.csdn.net/u010828718/article/details/50496495
2. "IOS9-the color of the status bar various problems" http://www.cnblogs.com/zw-ios/p/5387650.html
Status bar text color modification when iOS search