ios - preferredStatusBarStyle is not working -
this question has answer here:
- how set status bar style in swift 3 15 answers
i used use setstatusbarstyle in project , works fine, deprecated use preferredstatusbarstyle, didn't work. knowing i've:
- call method setneedsstatusbarappearanceupdate.
- set "view controller-based status bar appearance" no in info.plist
override function
- (uistatusbarstyle)preferredstatusbarstyle { return uistatusbarstylelightcontent; }
this function not called
note: i'm using navigation controller.
if want set status bar style, application level set uiviewcontrollerbasedstatusbarappearance no in .plist file. , in appdelegate > didfinishlaunchingwithoptions add following ine.
[uiapplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent animated:yes]; if wan set status bar style, @ view controller level follow these steps:
- set
uiviewcontrollerbasedstatusbarappearanceyesin.plistfile, if need set status bar style @ uiviewcontroller level only. in viewdidload add function -
setneedsstatusbarappearanceupdateoverride preferredstatusbarstyle in view controller.
-
- (void)viewdidload { [super viewdidload]; [self setneedsstatusbarappearanceupdate]; } - (uistatusbarstyle)preferredstatusbarstyle { return uistatusbarstylelightcontent; } 
Comments
Post a Comment