Xcode 9 borderColor在用户定义的运行时属性中不起作用 [英] Xcode 9 borderColor doesn't work in User Defined Runtime Attributes
问题描述
我正在使用此CALayer
扩展名:
var borderUIColor: UIColor {
set {
self.borderColor = newValue.cgColor
}
get {
return UIColor(cgColor: self.borderColor!)
}
}
我认为可能是由于此扩展,页面底部的Submit按钮的borderColor
并没有变成白色(如我所愿):
I thought that maybe because of this extension my borderColor
of the Submit button from the bottom of the page doesn't change to white (as I want it to be):
但是不,我挂了一个IBOutlet
并尝试直接设置如下颜色:
But no, I hooked up an IBOutlet
and tried to set directly the color like this:
submitButton.layer.borderColor = UIColor.white.cgColor
在viewDidLoad
,viewWillAppear
和viewDidAppear
中进行了设置,因为我知道在上次重大更新(iOS 10)中,帧渲染从根本上进行了更改(1000x1000帧的东西),现在也许有一些类似的更改.不过没有运气.
Did it in viewDidLoad
, viewWillAppear
and viewDidAppear
because I know that in the last big update (iOS 10) the frame rendering was changed fundamentally (the 1000x1000 frame thing) and maybe there were some similar alterations now. No luck, though.
我在iOS 9、10和11中进行了测试.这与操作系统无关,而与环境有关.我正在使用Xcode 9 Beta5.有什么想法要解决吗?
I tested in iOS 9, 10 and 11. It's not about the OS, rather about the environment. I'm using Xcode 9 Beta 5. Any ideas how to solve it?
推荐答案
尝试使用@objc
装饰var声明,如下所示:
try decorating your var declaration with @objc
like so:
@objc var borderUIColor: UIColor {
...
}
应该解决您的问题
这篇关于Xcode 9 borderColor在用户定义的运行时属性中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!