2017-04-10 68 views
0

我正在为tvOS创建应用程序。我试图设置一个UIButton的颜色,但不知道如何得到我的权利。如何在Swift中设置UIButton类型的颜色:.system for tvOS

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

我很高兴的结果,当按钮处于焦点,但是当按钮没有焦点,我得到一个丑陋的结果。绿色按钮有一个缺少角落半径的彩色图层。

enter image description here

如何正确颜色的按钮?

回答

0

buttonA.layer.cornerRadius = 10

0

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

你可以看看这个组件的更多细节的实现https://github.com/dcordero/FocusTvButton

相关问题