从昨天开始,我一直在寻找这种解决方案,以解决如何在全球范围内更改iOS设备状态栏(仅)的颜色。
在android中,我只是这样做:
var window = Window;
window.ClearFlags(WindowManagerFlags.TranslucentStatus);
window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
window.SetStatusBarColor(Android.Graphics.Color.Transparent);
window.SetBackgroundDrawable(GetDrawable(Resource.Drawable.gradient));
但是我在iOS中找不到这样的方法。
请帮助。谢谢
答案 0 :(得分:0)
You can do like this
UIView statusBar = UIApplication.SharedApplication.ValueForKey(new NSString("statusBar")) as UIView;
if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
{
statusBar.BackgroundColor = color.ToUIColor();
}
In my case color is passed as argument and is of type Xamarin.Forms.Color.
In addition you might want to set style of status bar across all pages, depending on your needs.
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleBlackOpaque</string>