Kahsn
Kahsn

Reputation: 1045

attributed text on UITextview in Storyboard nor working correctly

I have a ViewController with an UITextView on it. I have several paragraphs in UITextView and am trying to give different fonts and colors on each paragraph. In the last paragraph, I made it center aligned and changed the color to red. Just the last paragraph.

Here is a change I made in storyboard: enter image description here

And below image is what I see in storyboard. You can see the change is correctly being made. enter image description here

However, when I run the app the changes I made (center aligned, red color) are applied to all paragraphs in the textview when I only made the changes on one paragrpah. Is there a way to make changes only on certain parts of the text in UITextView??

Upvotes: 3

Views: 2626

Answers (1)

Dominic K
Dominic K

Reputation: 7075

I don't have Xcode with me right now, but I feel it might have to do with a bug in Xcode where setting attributed text in IB either doesn't work or gives the wrong result. Try the solutions here (which sadly still apply to iOS 9/Xcode 7), or if that doesn't work, you may have to just do it programatically (using NSAttributedString to set the text on the text view).

Upvotes: 2

Related Questions