UITextView Font size class not change
Asked Answered
R

3

5

I try to set font size class of UITextView in storyboard, but it always shows system font (default font, size and color). It shows the correct font if I don't set font size class.

Here's a screenshot:

Anybody know how to fix this?

Retrospect answered 20/3, 2015 at 10:41 Comment(0)
S
7

It is matter of 'selectable' property of UITextView.

Check the selectable property of UITextView in Storyboard Editor to set it YES.

and later in viewWillAppear set this property to NO.

textview.text = @"some text";
textview.selectable = NO;
Someway answered 20/3, 2015 at 11:1 Comment(2)
Do you know why this happens?Vivien
No idea..but doing above fixed my issue.Someway
L
2

Try this code

-(void)viewWillAppear:(BOOL)animated
{
     _linkTextView.editable = YES;
     _linkTextView.font = [UIFont systemFontOfSize:18.0f];
     _linkTextView.editable = NO;
} 

Instead of system font you can use your font.

Lithography answered 16/11, 2015 at 14:39 Comment(1)
This doesn't appear to answer the question. It seems like an attempt at a coded workaround, without explaining why it didn't work when the user tried setting it in Interface Builder. Also, you're setting it to a static system font, when we can infer from the question that the user is trying to achieve a font other than the system font.Yim
H
-1

You can use .attributedText on your TextView and set an AttributedString there, so you can easily customise your TextView.

NSString *yourString = "your text";
NSMutableAttributedString *ms = [[NSMutableAttributedString alloc] initWithString:yourString];
[ms addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:40] range:NSMakeRange(0, yourString.length)];
Hepato answered 19/6, 2018 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.