Xamawin • zam-ah win | noun
A quick, easy to implement enhancement for a Xamarin App that improves performance, appearance, or functionality
This XamaWIN, like they often do, comes after an embarrassing amount of time searching for a simple thing: changing the color of the statusbar text for iOS. By default, the text color is black until you add a new key to info.plist: UIViewControllerBasedStatusBarAppearance
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleIdentifier</key> <string>net.iwcs.sample</string> <key>CFBundleShortVersionString</key> <string>1.0.3.2</string> [...] <key>UIViewControllerBasedStatusBarAppearance</key> <false/> </dict> </plist>
I prefer to edit the xml directly, but you can also do this via the handy visual editor:
Then, just set the color wherever you initialize your NavigationPage, like so:
MainPage = new NavigationPage(new HomePage()) { BarTextColor = Color.White, BarBackgroundColor = Color.FromHex("#394A76"), };
The result looks fantastic. Check out the side-by-side below:
Credit to Trevi Awater for sharing the answer on this Stack Overflow post!
One thought on “XamaWIN – Changing the statusbar color in iOS”