How to display superscript for third power/cube characters as a string in UILabel?

后端 未结 2 1375
青春惊慌失措
青春惊慌失措 2021-02-10 13:42

I\'m trying to find solution for it and confused how do I display third power/ cube in a UILabel. I tried to find answer in previously asked question but none of them were usefu

2条回答
  •  北海茫月
    2021-02-10 14:29

    Another solution would be to use the Core Text framework to draw an NSAttributedString with the kCTSuperscriptAttributeName attribute on the section of the string you want to make superscript. This ends up being more work including custom drawing and things, but is more flexible than relying on unicode characters.

    Here’s a blog post I found with some more information: http://iphonedevelopment.blogspot.com/2011/03/attributed-strings-in-ios.html

    NSAttributedString on Mac OS X has lots of nice uses built into AppKit, but Apple hasn’t made it easy with UIKit for iOS.

提交回复
热议问题