【问题标题】:How to set color of UIButton type: .system for tvOS in Swift如何设置 UIButton 类型的颜色:.system for tvOS in Swift
【发布时间】:2017-04-10 19:00:47
【问题描述】:

我正在为 tvOS 创建一个应用程序。我正在尝试设置 UIButton 的颜色,但不知道如何正确设置。

var buttonA: UIButton(type: .system)
var buttonB: UIButton(type: .system)
...
buttonA.backgroundColor = UIColor.green
buttonB.backgroundColor = UIColor.red

当按钮处于焦点时,我对结果感到满意,但当按钮未处于焦点时,我会得到一个丑陋的结果。绿色按钮的彩色图层缺少其角半径。

如何正确地为按钮着色?

【问题讨论】:

    标签: swift uibutton tvos


    【解决方案1】:

    buttonA.layer.cornerRadius = 10

    【讨论】:

      【解决方案2】:

      这些值在开箱即用的 tvOS 的 UIButton 实例中不可自定义。您必须创建自定义解决方案才能拥有自定义布局。

      您可以查看此组件的实现以获取更多详细信息https://github.com/dcordero/FocusTvButton

      【讨论】:

        猜你喜欢
        • 2014-12-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-04-07
        • 2011-06-13
        • 2017-01-18
        • 1970-01-01
        相关资源
        最近更新 更多