I'm super unhappy with the way I've had to set the EFFING UIStatusBarStyle
of my app for iOS 7. Essentially I've got a custom presenter that sets up the SlidingPanels navigation (hamburger menu). Inside the custom presenter I define a RootController
, and this is where I'm confused/ticked off/annoyed... pick one. </rant>
Normally I would like to just do something like this and be done with it.
RootController = new UIViewController();
// this line won't work because PreferredStatusBarStyle is a Method Group and not a property WTF
RootController.PreferredStatusBarStyle = UIStatusBarStyle.LightContent;
But there seems to be no way to cleanly set properties in iOS. Therefore I'm stuck with this ugliness.
RootController = new CustomUiViewController();
//.....
public class CustomUiViewController : UIViewController
{
public override UIStatusBarStyle PreferredStatusBarStyle()
{
return UIStatusBarStyle.LightContent;
}
}
Then in the ViewDidLoad()
of every view, I have to call SetNeedsStatusBarAppearanceUpdate()
, and this is absurd to me.
Is there a cleaner/easier way to set this?
One of the side affects of the above approach is when the app is first loading, the StatusBar is still "dark" and therefore you can't see the clock until after ViewDidLoad()
.
Just add to your app's info.plist a couple keys:
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With