首页 > 解决方案 > 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

但是我在属性选择的下拉菜单中找不到任何称为斜体或粗体的内容。我错过了什么吗?

标签: swiftnsmutableattributedstringitalics

解决方案


推荐阅读