微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在13-Xamarin Forms下的IOS版本中更改状态栏图标的颜色?

如何解决如何在13-Xamarin Forms下的IOS版本中更改状态栏图标的颜色?

我只能在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();

解决方法

确保已在info.plist中添加了键值描述

View controller-based status bar appearance(默认值为是)。

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。