Search code examples
iosswiftstatusbar

How to Change the status bar color using ios with swift on internet reachability?


i want to change the color of my device status bar if the internet is connected than the status bar color should turn Black and if the internet is not connected the color or status bar should turn Red so that it indicates wether internet is working or not during working with the application using SWIFT...help me out


Solution

  • In your Info.plist you need to set "View controller-based status bar appearance" to a boolean value.

    If you set it to YES then you should override preferredStatusBarStyle function in each view controller.

    If you set it to NO then you can set the style in AppDelegate using:

    UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)