How to change StatusBar style in Objective-C (iOS 8)? -


i want change statusbarstyle, using preferredstatusbarstyle method , added "view controller-based status bar appearance" yes in plist, don't know, why not working? have mentioned following steps below:

step:1

// preferredstatusbarstyle method      -(uistatusbarstyle)preferredstatusbarstyle     {         cgrect screenrect = [[uiscreen mainscreen] bounds];         cgfloat sw = screenrect.size.width;         [[uiapplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];          uiview *statusview=[[uiview alloc]initwithframe:cgrectmake(0, 0,sw,20)];         statusview.backgroundcolor=[uicolor blackcolor];         [self.view addsubview:statusview];         return uistatusbarstylelightcontent;     } 

step:2

//add plist

view controller-based status bar appearance="yes"

step:3

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view.     [self preferredstatusbarstyle];  } 

please suggest me.

there no direct way of changing status bar color. can choose status bar style using “setstatusbarstyle” property , choose among 3 available styles –

uistatusbarstyledefault uistatusbarstyleblacktranslucent uistatusbarstyleblackopaque 

however if change color of status bar, there trick can same –

change background color of uiwindow object. , set status bar style “uistatusbarstyleblacktranslucent”. set color of status bar same background color of window.

add following code appdeligate.m file in applicationdidfinishlaunchingwithoptions –

self.window.backgroundcolor = [uicolor colorwithred:0.78f green:0.13f blue:0.11f alpha:1]; [application setstatusbarstyle:uistatusbarstyleblacktranslucent]; 

or check below tutorial customize status bar appcoda


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -