Example of NSAttributedString with two different font sizes?

后端 未结 4 665
孤街浪徒
孤街浪徒 2020-11-28 07:08

NSAttributedString is just really impenetrable to me.

I want to set a UILabel to have text of different sizes, and I gather NSAttrib

4条回答
  •  心在旅途
    2020-11-28 07:26

    Swift 4 Solution:

    let attrString = NSMutableAttributedString(string: "Presenting The Great...",
                                           attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 18)]);
    
    attrString.append(NSMutableAttributedString(string: "HULK HOGAN!",
                                            attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 36)]));
    

提交回复
热议问题