xcode 如何更改 uitextview 字体大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6517135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:00:06  来源:igfitidea点击:

How to change the uitextview font size

iphonexcodeuitextviewfont-size

提问by mychar

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

任何人都可以帮助更改UITextView.

[textView setFont:[UIFont fontWithName:@"ArialMT" size:30]];

I use this one but it doesn't work.

我使用这个,但它不起作用。

回答by iMOBDEV

Have you bind textView with xib or allocated textView?

您是否将 textView 与 xib 或分配的 textView 绑定?

If yes,

如果是,

You can use following code to check whether this works

您可以使用以下代码来检查这是否有效

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

or

或者

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

回答by brainray

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

检查是否在 xib/Storyboard 属性检查器中选中了“Selectable”。如果不可选,则尺寸不会改变

回答by Brian Ogden

Swift 4.0

斯威夫特 4.0

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

回答by Alex Terente

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

你的代码是正确的。问题出在代码的其他部分。提供有关 textView 的更多详细信息

回答by sadik hasan

Use this:

用这个:

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

回答by Dhruv Khatri

Here is for swift 3.0

这是 swift 3.0

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

回答by Alex Cio

I tried it the same way like you with

我和你一样试过

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

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

我设置了UITextView里面ViewDidLoad。我的问题是,我改变了我的看法:

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

My problem was solved with setting the properties of the UITextViewafter transforming my UIViewwhich includes the UITextView.

我的问题是与设定的性能解决UITextView转型后我UIView其中包括UITextView