Nori designs the view of the storyboard with source code.
Define the custom class that extends StyleableLabel
as @IBDesignable
. And implement the func intrinsicStyle() -> LabelStyle
.
import Nori
@IBDesignable class LargeLabel: StyleableLabel {
override func intrinsicStyle() -> LabelStyle {
return LabelStyle {
$0.textColor = Color.black.color
$0.font = UIFont.systemFont(ofSize: FontSize.large.point)
}
}
}
It's same as the Label.
@IBDesignable class StarButton: StyleableButton {
override func intrinsicStyle(for state: UIControlState) -> ButtonStyle {
return ButtonStyle {
$0.backgroundColor = Color.green.color
$0.cornerRadius = 10
$0.title = LabelStyle {
$0.textColor = UIColor.white
}
}
}
}
- View
- Button
- ImageView
- Label
- TextField
- Switch
Nori is released under the MIT license. See LICENSE for details.