Change font color of UITextView
You can fix this (at least in Xcode 8.2) in IB by toggling the textColor button (6th button in the row). With this button selected, if you set the textColor programmatically before you enter text in the view, the color will "stick." I have not found an elegant way to set this on the text view programatically.
However you can also work around this in code:
textView.text = @" ";
textView.textColor = UIColor.redColor;
textView.text = @"";
I just tried that and I had no problems. I set up a button that called [myTextView setTextColor:[UIColor redColor]];
After typing a bit with black text color, I pressed the button, and everything turned red. Then I continued typing, all in red.
Are you using setTextColor:
to do this also?
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.