Reputation: 3095
How do you change the color of text in a UITextView?
Upvotes: 10
Views: 15221
Reputation: 175
I spot that setting
_textView.selectable = true;
solves that strange issue.
Upvotes: 6
Reputation: 24685
In the end, setTextColor:
is the answer, there's an important detail missing from the earlier answers: To get this to work in iOS 8, I had to set the color =after= I set the text.
Hence,
- (void)viewDidLoad
{
[super viewDidLoad];
_myTextView.textColor = [UIColor whiteColor];
_myTextView.text = @"yadda yadda yadda...";
// etc., snip
Did NOT work, while
- (void)viewDidLoad
{
[super viewDidLoad];
_myTextView.text = @"yadda yadda yadda...";
_myTextView.textColor = [UIColor whiteColor];
// etc., snip
DID work. This strikes me as a bug in iOS 8, which I will write up.
Upvotes: 16
Reputation: 25632
yourTextView.textColor = [UIColor redColor];
Looking up UITextView in the documentation gives this immediately. ;-)
Upvotes: 21