ios - 如何更改 NSAttributedString 字体大小
问题描述
如何更改NSAttributedString
已初始化的字体大小
init(data: Data, options: [NSAttributedString.DocumentReadingOptionKey : Any] = [:], documentAttributes: AutoreleasingUnsafeMutablePointer<NSDictionary?>?)
实际上我有包含 html 标签的字符串,我使用Roger Carvalho给出的扩展名。html 标签已正确呈现,但字体与以下给出的常规字体不同FontSizeMetrics
:
let fontMetrics: FontSizeMetrics = FontSizeMetrics()
let font = UIFont(name: "NotoSans", size: fontMetrics.fontRegular)
解决方案
在 Swift 4 中:
[NSAttributedStringKey.font : UIFont.boldSystemFont(ofSize: 17.0)]
推荐阅读
- javascript - 反应:关闭一个模态点击外部
- python - DIctionary 确实按预期更新了内部字符串列表;而是返回 None
- python - 如何检查是否在窗口外的 TKinter 中按下了某个键?
- excel - Excel中更改字体颜色的按钮
- c# - EF Core 5 检索数据库多对多记录'值不能为空。(参数'源')'
- python - 使用for循环逐列遍历对象的非矩形嵌套列表
- javascript - 如何在 p5.js 中修改声音文件中的特定频率?
- c# - Json 格式在 Unity 中使用简单的 json 似乎无效
- text - 在 C++Builder 中使用上标
- c# - 如何在字符串中搜索文本并抓取搜索文本之后的所有内容,直到它到达一个字符?