【问题标题】:xamarin.forms, How to change app top layoutxamarin.forms,如何更改应用顶部布局
【发布时间】:2017-10-06 15:02:31
【问题描述】:

我需要对 ios 设备的应用程序顶部进行一些更改... Back 按钮是橙色的,但我需要它,而且只有它是白色的... 但是当我将页面标题更改为橙色时,它一起改变了......

我在“AppDelegate”中使用了这一行:

UINavigationBar.Appearance.SetTitleTextAttributes(
    new UITextAttributes() { TextColor = UIColor.Orange });

除此之外,我的状态栏是白色的...我在 appDelegate 中使用它将其更改为黑色:

if (statusBar.RespondsToSelector(new ObjCRuntime.Selector("setBackgroundColor:")))
        {
            statusBar.BackgroundColor = UIColor.White;
        }

我可以做黑色,但我需要它的字母是白色的...我搜索了,但我找不到有效的答案...请,如果可以,请帮助我 这对我来说真的很重要

【问题讨论】:

    标签: ios xamarin mobile layout xamarin.forms


    【解决方案1】:

    1.

    这会将标题颜色设置为橙色:

    UINavigationBar.Appearance.SetTitleTextAttributes(new UITextAttributes()
    {
        TextColor = UIColor.Orange
    });
    

    这会将 BackButton 颜色设置为白色:

    UINavigationBar.Appearance.TintColor = UIColor.White;
    

    2.

    要更改状态栏外观,请点击此链接:Change Status Bar Icon & Text Colors

    【讨论】:

    • 我正在使用 UINavigationBar.Appearance.TintColor = UIColor.White;它不会改变文本颜色
    • 你能在 FinishedLaunching() 中发布你的完整代码
    • 我现在是问题所在,朋友。问题是这个
    • 上面的 xaml 代码应该适用于 iOS 和 Android。
    【解决方案2】:

    可以使用 Xamarin Forms 代码在您想要的 ContentPage 上更改文本:

    在 C# 代码中:

    NavigationPage.SetBackButtonTitle (this, "Something Other Than Back");
    

    在 XAML 中:

    <ContentPage NavigationPage.BackButtonTitle="Back">
    

    仅更改后退按钮颜色需要自定义渲染器。查看this 帖子,了解在 iOS 上控制后退按钮属性的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-28
      • 2019-09-09
      • 2014-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多