-
-
Notifications
You must be signed in to change notification settings - Fork 214
3. Styling
S4cha edited this page Jan 8, 2017
·
1 revision
Well, just call style
on a UIView subclass :
In-line for small or unique styles
detail.style { l in
l.numberOfLines = 0
l.textAlignment = .Center
l.textColor = .blueColor()
l.text = NSLocalizedString("NeedPetMessage", comment: "")
}
Or in a separate to make them reusable
// My style method, kinda like CSS
func detailStyle(l:UILabel) {
l.numberOfLines = 0
l.textAlignment = .Center
l.textColor = .blueColor()
l.text = NSLocalizedString("NeedPetMessage", comment: "")
}
// Later
{
// Set my style
detail.style(detailStyle)
}
This is the preferred way because the styles become reusable and composable: you can chain them! You can even create a Style File grouping high level functions for common styles. Usage then becomes very similar to CSS!