我在下面定义了UILabel
:
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
}()
现在的问题是,在iphone 4等旧款手机上,文字行不适合一行。我认为这可以通过label.adjustsFontSizeToFitWidth = true
行解决,但不是适当缩小文本大小,标签文本显示如下:By logging in, you agree to our Privacy Policy...
我不能让这个标签有多行,因此我不能使用numberofLines = 2
或label.lineBreakMode = NSLineBreakMode.ByTruncatingTail
在这种情况下绝对必要的是整行文字在一行中可见。我怎样才能做到这一点?
答案 0 :(得分:0)
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.