SwiftyAttributes 用于属性字符串的Swifty API。 使用SwiftyAttributes ,您可以像这样创建属性字符串: let fancyString = " Hello World! " . withTextColor (. blue ). withUnderlineStyle (. styleSingle ) 或者,使用Attribute枚举: let fancyString = " Hello World! " . withAttributes ([ . backgroundColor (. magenta ), . strokeColor