Reputation: 569
I change my text size like following image.
But my app doesn't change the the font size.
Have any idea to me?
label.font = UIFont.systemFont(ofSize: 16.0)
label.adjustsFontForContentSizeCategory = YES
label.text = string
Upvotes: 0
Views: 855
Reputation: 20379
From iOS 10 onwards you can support dynamic font sizes using one line :)
Change your
label.font = UIFont.systemFont(ofSize: 16.0)
to use,
label.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.headline)
You can specify the font style you need for your label :)
Refer : https://developer.apple.com/documentation/uikit/uifont/1619030-preferredfont
Upvotes: 3
Reputation: 2425
There is a simpler solution. Just add below lines-
SWIFT 3:
label.minimumScaleFactor = 0.1 //or whatever suits your need
label.adjustsFontSizeToFitWidth = true
label.lineBreakMode = .byClipping
label.numberOfLines = 0
Upvotes: 0