[英]How to change NSAttributedString font size
How can I change the font size of a NSAttributedString
that has been initialized with 如何更改已使用初始化的
NSAttributedString
的字体大小
init(data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
Actually I have strings that contain html tags, I use the extension given here by Roger Carvalho. 实际上,我有包含html标签的字符串,我使用的是Roger Carvalho 在此处给出的扩展名。 The html tags are correctly rendered but the font is not the same as the regular one given by
FontSizeMetrics
: 正确标记了html标记,但是字体与
FontSizeMetrics
给出的常规标记不同:
let fontMetrics: FontSizeMetrics = FontSizeMetrics()
let font = UIFont(name: "NotoSans", size: fontMetrics.fontRegular)
在Swift 4中:
[NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 17.0)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.