开发者

How to change the uitextview font size

can any one help to change the font size in UITextView.

[textView setFont:[UIFont font开发者_C百科WithName:@"ArialMT" size:30]];

I use this one but it doesn't work.


Have you bind textView with xib or allocated textView?

If yes,

You can use following code to check whether this works

[textView setFont:[UIFont boldSystemFontOfSize:15]];

or

 [textView setFont:[UIFont systemFontOfSize:15]];


Check, if "Selectable" is checked in the xib/Storyboard attribute inspector. If it's not selectable, the size wont be changed


Swift 4.0

textField.font = UIFont.systemFont(ofSize: 17.0)


   UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
   [textView  setFont: [UIFont fontWithName:@"ArialMT" size:30]];
   textView.text = @"test my font size";
   [self.view addSubview:textView];
   [textView release];

Your code is correct. The problem is from other part of your code. Provide more details about your textView

Set custom font and size in Swift:

textView.font = UIFont(name: "ArialMT", size: 20)


Use this:

UITextView *myTextView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];  
myTextView.font = [UIFont fontWithName:@"arial" size:14];


Here is for swift 3.0

textview.font = UIFont(name: textview.font.fontName, size: 18)


I tried it the same way like you with

[textView setFont:[UIFont fontWithName:kFontName size:kFontSize]];

I set the UITextView inside ViewDidLoad. My problem was, I transformed my view:

[_viewEnd setTransform:CGAffineTransformMakeScale(0.0, 0.0)];

My problem was solved with setting the properties of the UITextView after transforming my UIView which includes the UITextView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜