我正在使用Xcode 7.当使用自定义字体的属性文本时,它会显示在故事板中但不在设备上运行。我尝试了以下代码:
var myMutableString = NSMutableAttributedString()
let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 8
paragraphStyle.alignment = NSTextAlignment.Center
myMutableString = NSMutableAttributedString(string: "\"Taking out my shorts and T-Shirt a night before has helped create a great morning routine for my walk\"", attributes: [NSFontAttributeName:UIFont(name: "Gotham Medium", size: 20.0)!])
myMutableString.addAttribute(NSParagraphStyleAttributeName, value:paragraphStyle, range:NSMakeRange(0, myMutableString.length))
quotesLabel.attributedText = myMutableString
答案 0 :(得分:1)
确保您的应用包含 Gotham Medium 的字体文件。查看这篇关于Common Mistakes With Adding Custom Fonts in iOS Apps的精彩文章。