Adding underline attribute to partial text UILabel in storyboard

22,155

Solution 1

  1. select the UILabel and go to Attribute Inspector section.
    Change the text value from plain to Attributed .

    enter image description here

  2. Select the particular part of text which you want to Underline .

    Note: If u want full text to be Underline select full text.

    enter image description here

  3. Now right click and change the font to Underline.

    enter image description here

It will Underline the text

enter image description here

Solution 2

Steps:-

  1. Go to TextEdit and create your UILabel text with underline.
  2. Change UILabel text to Attributed (Attributed Selector).
  3. Copy Underlined text and assign to UILabel.
Share:
22,155
C3332
Author by

C3332

Updated on February 01, 2020

Comments

  • C3332
    C3332 over 4 years

    How can I underline partial text of UILabel using only storyboard? I am able to do this in code and I'm able to underline the entire text of a label, but not just one or two words in the string.

  • David West
    David West about 8 years
    So useful thanks - strange how Apple hid all that functionality away!
  • Kautham Krishna
    Kautham Krishna about 8 years
    This answer works in iPhone 5s but does not show the underline in 6 and 6 plus devices. Is there any other way
  • iPhone 7
    iPhone 7 almost 8 years
    saved my life spent more than an hour searching on it
  • karique
    karique over 5 years
    i've been looking for this for a long time, thank you sir.
  • PhillipJacobs
    PhillipJacobs over 4 years
    Such an easy solution! Thanks @RizwanShaikh 🔥👨🏽‍💻🕷
  • Tornike Gomareli
    Tornike Gomareli almost 4 years
    I have searched the whole StackOverflow and this is the easiest and most simple solution I have found. Thank you very much. Being Senior developer is not about knowing every detail how to make from code, it is just hiding in simplicity.
  • Vinoth Anandan
    Vinoth Anandan about 3 years
    Question is to apply, underline in the storyboard. For coding, we have answers in stackoverflow.com/questions/28053334/…