I have created a subclass of UILabel in Swift i want to customize some properties of label like fonts,color size etc based on which type of label it is.
This label is created in storyboard file. For identifying the type of labe i have created a custom property name 'labelType' this labelType will never change it's value once it has been assigned. So we should create this property is 'let' but the issue is we need to defined this property before it's initWithCoder is called.
How can we set it's inital value in initWithCoder dynamically ? (or any other default constructor ? )
currently i have make the property as var and i am setting that property's value from storyboard itself (User defined runtime attributes)
Here is the code
class BMLabel: UILabel {
var labelType:NSNumber!
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
override func awakeFromNib() {
self.setUpProperties()
}
func setUpProperties() {
switch(labelType) {
case 1:
self.font = Constants.FONTS.LIST_UUID_FONT