I want to set the default text color for all UILabels in my app. I found this:
UILabel.appearance().textColor = UIColor.red
This works, but whe
SubClass you labels with CustomLabel.swift. You can set text color using IBDesignable
property named as txtColor
Below is the code working example
import UIKit
@IBDesignable class CustomLabel: UILabel {
@IBInspectable var txtColor: UIColor = UIColor.grayColor() {
didSet {
self.textColor = txtColor
}
}
func setup() {
self.textColor = txtColor
}
override func awakeFromNib() {
setup()
}
override func prepareForInterfaceBuilder() {
setup()
}
}