Forum Xamarin.iOS


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Change status bar colour on iOS13

Before iOS 13 I could change the status bar colour using the following bit of code:

        UIView statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
        if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
            statusBar.BackgroundColor = UIColor.Clear.FromHex(0x323232);
            statusBar.TintColor = UIColor.White;
            app.StatusBarStyle = UIStatusBarStyle.BlackOpaque;

However, on iOS13 I get the following runtime error

Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.

Any idea on how to change the status bar on iOS13?


  • LandLuLandLu Member, Xamarin Team Xamurai

    You can't obtain the status bar through the ValueForKey on iOS 13. You could consume the code below to find or create the view:

    UIView GetStatusBar()
        UIView statusBar;
        if (UIDevice.CurrentDevice.CheckSystemVersion(13, 0))
            int tag = 123; // Customize this tag as you want
            UIWindow window = UIApplication.SharedApplication.Windows.FirstOrDefault();
            statusBar = window.ViewWithTag(tag);
            if (statusBar == null)
                statusBar = new UIView(UIApplication.SharedApplication.StatusBarFrame);
                statusBar.Tag = tag;
                statusBar.BackgroundColor = UIColor.Red; // Customize the view
            statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
        return statusBar;
  • Hi LandLu thanks for quick response but its not work for my IOS 13.0.
    I put your code in app delegate there is no error occur but also not showing status color as per my..

  • Ludo11100Ludo11100 Member ✭✭

    Same, since the update exeption thrown

  • thisismyselfthisismyself Member ✭✭

    @LandLu Thanks for this piece of code. But where would be the correct place to call this code? I tried in bool FinishedLaunching(UIApplication app, NSDictionary options), it created a new UIView object but nothing was colored in any other way than before.

Sign In or Register to comment.