NSAttributedString superscript styling

后端 未结 4 550
南笙
南笙 2020-11-29 04:27

I want to superscript all the instances of ® character in a block of text (legal disclaimer, naturally ;)) and the default way NSAttributedString is not very go

4条回答
  •  粉色の甜心
    2020-11-29 05:00

    Swift 5

        let fnt = UIFont(name:"Helvetica", size:20.0)
        let attributedString = NSMutableAttributedString(string:"2.099", attributes:[NSAttributedString.Key.font : fnt!])
        attributedString.setAttributes([NSAttributedString.Key.font : fnt!.withSize(10), NSAttributedString.Key.baselineOffset: 10], range: NSRange(location: 4, length: 1))
    

提交回复
热议问题