How do you use NSAttributedString?

后端 未结 15 1112
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 04:19

Multiple colours in an NSString or NSMutableStrings are not possible. So I\'ve heard a little about the NSAttributedString which was introduced wit

15条回答
  •  没有蜡笔的小新
    2020-11-22 05:00

    To solve such kind of problems I created library in swift which is called Atributika.

    let str = "firstsecondthird".style(tags:
            Style("r").foregroundColor(.red),
            Style("g").foregroundColor(.green),
            Style("b").foregroundColor(.blue)).attributedString
    
    label.attributedText = str
    

    You can find it here https://github.com/psharanda/Atributika

提交回复
热议问题