Cesare Cesare - 5 months ago 30
Swift Question

Change font of labels with @IBDesignable

This is a class that is supposed to change the font of a label dynamically, right in the Storyboard:

@IBDesignable class FlexibleLabel: UILabel {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.font = UIFont(name: "Brandon Grotesque", size: self.font.pointSize)
}
}


I assigned this class to some labels but I get this error:


Failed to update auto layout status: The agent crashed.


What can I do to fix this?

Answer

The first method which is called after the view is fully initialized from nib is UIView's awakeFromNib() method. You can override and use it to modify view's or subviews properties

Comments