swift - NSMutableAttributedString(Xcode)中的斜体和粗体在哪里?
问题描述
我有一个大字符串,我希望它的一部分是斜体或粗体。我已经成功地用来NSMutableAttributedString
改变某些属性。见下文:
let attributedString = NSMutableAttributedString.init(string: "Testing Bold")
attributedString.addAttribute(.foregroundColor, value: UIColor.blue, range: NSRange.init(location: 0, length: 5))
testlabel.attributedText = attributedString
但是我在属性选择的下拉菜单中找不到任何称为斜体或粗体的内容。我错过了什么吗?
解决方案
推荐阅读
- reactjs - 如何避免在带有钩子的组件中进行不必要的渲染
- html - 在 Thymeleaf 中插入模板而不覆盖子项(默认头模板)
- python - 如何处理 Python 子进程调用错误和等待
- node.js - MongoDB NodeJS 总是在一分钟后过期
- r - 我可以在 R 中指定时间序列的日期和时间吗?
- reactjs - Redux 操作的正确返回类型
- javascript - 用javascript反转二叉树
- javafx - 当用户单击 FileChooser 框 JavaFX 上的取消或“X”时如何处理 NullPointerException
- c# - 为什么 Debug.Assert 显示错误消息,即使 Length 一直是 1?
- regex - 在某个字符之后查找所有匹配项