xamarin - 如何更改 Xamarin Forms 中的文本颜色状态栏?
解决方案
好的,@Harry Android 与 IOS 不同。
现在我的首要任务是Android,所以是的。iOS 可能在未来
安卓:
Android 6.0 开始,Google 官方提供支持,android:windowLightStatusBar
在 style 属性中配置 是,当设置为true
时,当状态栏的背景颜色为浅色时,状态栏的文字颜色会变灰。同理true
。false
如下:
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
...
<item name="android:windowLightStatusBar">false</item>
</style>
在 xamarin.forms 中可以点击此链接获得成功。
基本上你必须使用FormsAppCompatActivity
代替FormsApplicationActivity
和Theme.AppCompat.Light.NoActionBar
代替Theme.Material.Light
。
如果希望某些页面显示不同的样式,可以在活动的主题中进行更改。
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".Activity.SecondActivity"
android:launchMode="singleTop"
android:theme="@style/customttheme"/>
</application>
IOS:
info.plist
(1)、在Project.IOS中添加follow key-value :
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
(2) 不使用代码:
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
(3),或者使用代码设置状态栏的文字颜色,设置方法FinishedLaunching
如下AppDelegate.cs
:
app.StatusBarStyle = UIStatusBarStyle.LightContent;
(4)如果想在启动应用后某些页面改变颜色,可以为IOS自定义 ,方法:ViewControllerRenderer
ViewDidLoad()
UIApplication.SharedApplication.StatusBarStyle = UIStatusBarStyle.LightContent;
推荐阅读
- java - Spring Boot 和 Jquery 从前端的 hashmap 访问值
- java - 如何使用我的粒子发射器传递模式?
- wordpress - 如何使用 .htaccess 访问 404 页面
- xcode - how can I use facebook sdk swift 4.1 branch for ios
- scala - Simple play/scala benchmark, rendering a view versus a raw text output comparison
- java - How can I display dishName according to the searched price after sorting in jtable java?
- google-apps-script - Cannot convert sheet row to class error in google script
- notepad++ - 如何用 .xml 文件中的一个特定值替换多行代码中不同值的数字?
- python - 与线程一起使用时,cv2 imshow 在关闭并再次打开后不再打开窗口
- ios - 如何使 UIPageViewController 的缓存页面失效?