Please initialize Fount in WormTabStripButton also , because if you don't initialize then font and size will not reflect first time
so i use -> self.font = AppTheme.TabStripFont()
class WormTabStripButton: UILabel{
var index:Int?
var paddingToEachSide:CGFloat = 10
var tabText:NSString?{
didSet{
let textSize:CGSize = tabText!.size(withAttributes: [NSAttributedStringKey.font: font])
self.frame.size.width = textSize.width + paddingToEachSide + paddingToEachSide
self.text = String(tabText!)
}
}
//MARK: init
override init(frame: CGRect) {
super.init(frame: frame)
self.font = AppTheme.TabStripFont()
}
convenience required init(key:String) {
self.init(frame:CGRect.zero)
self.font = AppTheme.TabStripFont()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Please initialize Fount in WormTabStripButton also , because if you don't initialize then font and size will not reflect first time
so i use -> self.font = AppTheme.TabStripFont()
class WormTabStripButton: UILabel{
}