问题描述
我只能在Xamarin Forms App的13下的IOS版本中更改状态栏图标的颜色。我已经这样做了,并且可以在13以上的IOS版本上很好地工作。我可以更改背景颜色,但是我不需要它,我需要图标本身。
看例子: 这段代码仅用于更改状态栏BackgroundColor,我设置了status.TintColor,但它不会更改...
private void ChangeStatusBar()
{
UIView statusBar = UIApplication.SharedApplication.ValueForKey(new Nsstring("statusBar")) as UIView;
if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
{
statusBar.BackgroundColor = UIColor.White;
statusBar.TintColor = UIColor.White;
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
}
}
在13以上的IOS版本中,我使用它来更改状态栏图标的颜色,并且可以正常工作:
UIApplication.SharedApplication.SetStatusBarStyle(isLightTheme ? UIStatusBarStyle.LightContent : UIStatusBarStyle.DarkContent,false);
GetCurrentViewController().SetNeedsstatusBarappearanceUpdate();