Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding underline to UILabel attributed string from the storyboard fails

  1. From the storyboard I select the UILabel in question
  2. Then in Attribute Inspector > Label > [I choose] Attributed
  3. Also in Attribute Inspector > Label > Text> [I select the content]
  4. Then I click on the font icon and choose underline

Basically, any change that I select from the Fonts window that pops up does not take effect.

Has anyone ever successfully add underline from the storyboard?

Note: I already know how to do this in code. I want to avoid adding code.

like image 534
Katedral Pillon Avatar asked Aug 02 '14 21:08

Katedral Pillon


People also ask

How do I underline a label in Xcode?

Select the text of the label, right click and change the font to 'underline'.

How do you underline text in Swift?

swift 3/4/5 Select range of text which you want to underline. Right click and choose Font then select underline.


2 Answers

Here is the solution in storyboard: Open the Attribute Inspector (make sure label is selected), Change the dropdown value from 'Plain' to 'Attributed'. Now a a small text editor will be visible under the font of the label. Select the text of the label, right click and change the font to 'underline'.

I also have attached a screenshot and successfully underlined a text using storyboard in XCode 7.0.1enter image description here

like image 74
Abdullah Saeed Avatar answered Sep 28 '22 09:09

Abdullah Saeed


Underline your text in TextEdit(cmd-U) and copy-paste it in Attribute Inspector > Label > Text > Attributed.

like image 40
Uladzimir Avatar answered Sep 28 '22 09:09

Uladzimir