【问题标题】:BarButtonItems not visible in iOS 11BarButtonItems 在 iOS 11 中不可见
【发布时间】:2017-09-21 15:09:48
【问题描述】:

我有一个使用 Xamarin 开发的 iOS 应用程序。现在我正在尝试将其迁移到 iOS 11。我的问题是导航栏中的所有 BarButtonItem 在任何控制器中都不可见,但它们可以正常工作,我可以点击它们。

通过将导航项添加到控制器中,可以在情节提要中设置其中一些按钮项。这些按钮项的标题也是不可见的。甚至是标准的后退按钮。

其他条形按钮项由 SetRightBarButtonItem 或 SetLeftBarButtonItem 在代码中设置。我有自定义图标按钮和系统项目按钮。系统项目按钮的示例是:

this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(UIBarButtonSystemItem.Stop, (sender, e) => { ... }), true);

另一个带有自定义图标的按钮:

this.NavigationItem.SetRightBarButtonItem(new UIBarButtonItem(UIImage.FromBundle("gear"), UIBarButtonItemStyle.Plain, (sender, e) => { ... }), true);

这些导航栏按钮项目已经运行了很长时间没有问题。如何使用 iOS 11 中的新导航栏结构修复它们? (我没有在导航栏中启用大标题)

【问题讨论】:

  • 在最新版本的 VS 中使用 Xamarin.iOS 11.0.0.0 重新添加它们会起作用吗?
  • 在 iOS 11 中,NavigationBars 现在默认使用 AutoLayout 呈现。尝试在自定义图像视图及其容器上设置一些高度和宽度布局约束。

标签: xamarin.ios uibarbuttonitem ios11


【解决方案1】:

做这样的事情。

var button = new UIBarButtonItem(UIImage.FromBundle("gear"),UIBarButtonItemStyle.Plain, (sender, e) => { ... });

button.SetTitleTextAttributes(new UITextAttributes()
            {
                TextColor = UIColor.Blue,
                TextShadowColor = UIColor.Clear
            }, UIControlState.Normal);

this.NavigationItem.SetRightBarButtonItem(button, true);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    • 2016-05-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多