yonaskolb / Stylist

Define UI styles for iOS apps in a hot-reloadable yaml or json file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enabling Stylist designable

drekka opened this issue · comments

Using Carthage, Stylist is added to my project as a framework. This means that the @IBDesignable and @IBInspectable annotations are not visible to IB and therefore I'd have to set the styles programmatically.

Instead I added the following code to the project and thought you might want to provide it as a work-a-round for other people. Just add it to the project where Stylist is being included as a framework.

import Stylist
import UIKit

/// Extensions to enable IB

@IBDesignable extension UIView {
    @IBInspectable var styleName: String? {
        get { return style }
        set { style = newValue }
    }
}

@IBDesignable extension UIViewController {
    @IBInspectable var styleName: String? {
        get { return style }
        set { style = newValue }
    }
}

@IBDesignable extension UIBarItem {
    @IBInspectable var styleName: String? {
        get { return style }
        set { style = newValue }
    }
}

Note: I don't use CocoaPods so I'm not sure if it will have the same issue.