【发布时间】:2019-06-05 20:31:27
【问题描述】:
尝试使用systemBlueColor 作为按钮的背景。
[myButton setBackgroundColor:[UIColor systemBlueColor]];
但是,我收到错误 No known class method for selector 'systemBlueColor'
如果我使用 blueColor 或 greenColor 等非自适应颜色,则效果很好。有什么想法吗?
谢谢!
【问题讨论】:
-
这是 iOS 13 的新功能。
-
啊,没想到。 @rmaddy还有其他方法可以将背景设置为系统蓝色吗? (目标-C)
-
不是在 iOS 13 之前。你必须硬编码你想要的颜色。
-
@rmaddy 即使我以这种方式获得系统颜色也不行? stackoverflow.com/questions/19032940/…
-
这可能行得通。但是如果
tintColor从未设置过,而你默认得到蓝色,那么tintColor就是nil,它对设置背景颜色没有帮助。