Search code examples
ioscolorsstatusbar

Changing status bar color on button click - iOS


If I were wanting to change the status bar's color from white to black when I click a button, how would I do that? I'm not using this for a app or any practical purpose but I just want to see how it would look.

Thanks :)


Solution

  • If you want to change your status bar appearance from UIStatusBarStyleDefault to UIStatusBarStyleLightContent

    on button click call below method ->

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
    

    For that to work you have to set View controller-based status bar appearance as NO in app plist keys.