Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAppearance, see result in Interface Builder?

I'm using UIAppearance a lot for my navigation controllers and other UI objects, and I was wondering if it's possible to have my related objects styled in Interface Builder (maybe with some magic voodoo of @IBDesignable?)

like image 472
allaire Avatar asked Jan 25 '15 19:01

allaire


1 Answers

matt's comments on the question are correct. You're able to successfully use UIAppearance proxies in the prepareForInterfaceBuilder method.

Example:

@IBDesignable
class MyCustomView: UIView {

    override func prepareForInterfaceBuilder() {
        MyCustomView.appearance().backgroundColor = UIColor.redColor()
    }
}

This will result in all MyCustomView instances to be rendered red in IB.

like image 118
Sandy Chapman Avatar answered Oct 19 '22 22:10

Sandy Chapman