Status bar text color modification when iOS search

Source: Internet
Author: User
Tags uikit

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.