I would like to ask, have any ways to change all Font, Size for Label by single code? Like Dynamic Type inside the app. ex: Android have been supported with the XML file (dimens)
Thank you!
There are a few ways to achieve that
UILabel
s:extension UILabel {
@nonobjc
convenience init() {
self.init(frame: .zero)
self.font = UIFont.systemFont(ofSize: 12, weight: UIFontWeightThin)
//... here goes other changes
}
}
You will need to use a convenience init every time.
UILabel
:class CustomLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
self.font = UIFont.systemFont(ofSize: 12, weight: UIFontWeightThin)
//... here goes other changes
}
required init?(coder: NSCoder) {
super.init(coder: coder)
self.font = UIFont.systemFont(ofSize: 12, weight: UIFontWeightThin)
//... here goes other changes
}
}
UILabel
.