我以这种方式创建了一个NSAttributedString
attribute3=[
NSForegroundColorAttributeName: innercircleColor,
NSFontAttributeName:UIFont.init(name: "Bariol", size: 18.0)!]
attriType=NSAttributedString.init(string: type, attributes: attribute3)
lblType.setAttributedText(attriType)
,但根据我的UILabel
尺寸,在iPhone 5s中,此属性文本正在Uilabel外面。如何使属性文本字体大小适合 UILabel
宽度
您想要的是UILabel
上的adjustsFontSizeToFitWidth
属性。它将自动大小Font
以适合框架。
您还可以设置用于使用numberOfLines
属性设置文本的行数,以及该字体应扩展为使用minimumFontSize
属性的最小尺寸。
https://developer.apple.com/documentation/uikit/uilabel/1620546-achjustsfontsizetsizetofitwidth