I have a UILabel
defined below :
let disclaimerLabel : TTTAttributedLabel = {
let label = TTTAttributedLabel(frame: CGRectZero)
label.textColor = UIColor.whiteColor()
label.font = UIFont.boldSystemFontOfSize(13)
label.textAlignment = .Center
label.numberOfLines = 1
label.minimumScaleFactor = 0.01
label.adjustsFontSizeToFitWidth = true
label.text = "By logging in, you agree to our Privacy Policy and T&C."
return label
}()
Now the problem is that on older phones such as iphone 4, the line of text does not fit within one line. I thought this would be solved by the label.adjustsFontSizeToFitWidth = true
line, however instead of shrinking the text size appropriately, the label text appears like this : By logging in, you agree to our Privacy Policy...
I cannot have this label have more than one line, therefore I cannot use numberofLines = 2
or label.lineBreakMode = NSLineBreakMode.ByTruncatingTail
It is an absolute necessity in this case that the whole text is visible in one line . How can I achieve this?
If your device is exactly iPhone 4 (so it runs iOS 7.0 or less), that's the point.
The property .adjustsFontSizeToFitWidth is available on iOS SDK 8.0 and later:
https://developer.apple.com/reference/uikit/uilabel/1620546-adjustsfontsizetofitwidth
If you need one line only for a label, use .minimumScaleFactor
for ios lower than 8.0 instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.