I placed a large text in a UITextView In Xcode in interface builder. Is it possible to assign different attributes (colors, headings, alignments..etc) to different parts of the string. Using MutableAttributedString
would not work for me since the string is longer than 5000 words, it would take ages to format it.
Asked
Active
Viewed 91 times
0

bibscy
- 2,598
- 4
- 34
- 82
-
yea! possible if you doing pragmatically :) – Nazmul Hasan Mar 30 '17 at 05:09
-
If I remember well you can do it in XCode, but it's not "easy" (especially when you do a mistake to correct it): Select part of the text, and then change the font, etc. To change line, do it with Alt+Enter, etc. Else, you can enter open the file as Source File, and mofify yourself the xml. – Larme Mar 31 '17 at 10:07
1 Answers
2
There is a simple way to do this. Outside Xcode :)
Open TextEditor
in MAC
and paste your text into it and format it as per your requirement and again copy it.
Now Add your UITextView
into your ViewController
in Storyboard
and make that textView Attributed.
Now Paste your formatted text there in the text field.
Check below screenshot for reference.
Hope this will help you.

CodeChanger
- 7,953
- 5
- 49
- 80
-
that's a nice hack. I will still wait to see if anyone else can do it in Xcode, though I doubt, and then I will accept your answer since this workaround provides the desired result. – bibscy Mar 30 '17 at 05:27