Search code examples
swiftstringuibuttonuilabelnsattributedstring

cos⁻¹ button title in Swift


I have an calculator app, and current the cos⁻¹ button looks like this:

enter image description here

But I want it to look like this:

enter image description here

What is the easiest way of accomplishing this? Is there any way of doing this without messing with NSAttributedString? Are there any special characters that I can use?


Solution

  • That's perfectly doable. There are unicode characters for superscripted digits and the "-" sign. Just paste the string cos⁻¹ into your button title, label, or other view with text content. (You can even copy/paste from this answer)

    I got the characters from this link:

    https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts