Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

textView configured in IB of iOS 7 change font back to default font after the text property is changed programmatically

NOTE: The time when I asked this question was when Apple just released iOS 7. Apple reimplemented UITextView with Text Kit after iOS 7. UITextView had some bugs that time. The issue of this question was one of them. But now it's fixed.


There is a UITextView in my app which is configured in IB. The text view has some default text of which the font size is 60.0f. The text view uses plain string to render text. If I change the text property of the text view programmatically when the app is running:

self.textView.text = @"some text different from default text";

the text view will change the font back to the default font.

configure font programmatically can solve this problem:

self.textView.font = [UIFont systemFontOfSize:60.0f];

This is a bug of the new UITextView.

like image 605
wcd Avatar asked Jan 10 '14 11:01

wcd


2 Answers

It's strange behaviour appears when you uncheck Selectable in IB. If you check Selectable, your Text View have got correct font. You can add textView.selectable = NO in code if you don't want to select it

like image 160
hash3r Avatar answered Sep 22 '22 10:09

hash3r


Did u notice the T symbol in the right croner of font tab use this for set the font size enter image description here

like image 42
LML Avatar answered Sep 23 '22 10:09

LML