Search code examples
ioscalayerios11xcode9-betaxcode9

Xcode 9 borderColor doesn't work in User Defined Runtime Attributes


I'm using this CALayer extension:

var borderUIColor: UIColor {
    set {
        self.borderColor = newValue.cgColor
    }

    get {
        return UIColor(cgColor: self.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):

enter image description here

But no, I hooked up an IBOutlet and tried to set directly the color like this:

submitButton.layer.borderColor = UIColor.white.cgColor

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.

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?


Solution

  • try decorating your var declaration with @objc like so:

    @objc var borderUIColor: UIColor {
    ...
    }
    

    that should fix your problem