首页 > 解决方案 > 未在 IOS 13 中附加的 NSMutableAttributedString 在 iOS 12 或更低版本中运行良好

问题描述

下面的代码在 iOS 12 或更低版本中运行良好,但在 iOS 13 中无法附加,因为它只打印First Line并且无法打印Extra Text

    let formattedString = NSMutableAttributedString()                                                                 
    formattedString.append(NSAttributedString(string: "First Line\n" ,
                                                          attributes:[NSAttributedStringKey.font:UIFont.systemFont(ofSize: 8.0), NSAttributedStringKey.foregroundColor : UIColor.white]))
    formattedString.append(NSAttributedString(string: "Extra Text", attributes: [NSAttributedStringKey.foregroundColor : UIColor.white]))
    self.setAttributedTitle(formattedString, for: .normal)

标签: iosswiftnsmutableattributedstring

解决方案


推荐阅读