简体   繁体   English

iPhone中的文本视图字体类型和大小

[英]Text View font type & size in iphone

i am using below code to change the the font type of text view. 我正在使用下面的代码来更改文本视图的字体类型。 but its not changing the font 但它没有改变字体

textView3.font = [UIFont fontWithName:@"Helvetica" size:17.0f]; textView3.font = [UIFont fontWithName:@“ Helvetica”大小:17.0f]; tell me where i am wrong. 告诉我我错了。

Use: 采用:

textview.font = [UIFont fontWithName:@"Arial" size:FontSize]; 

Where FontSize is an int . 其中FontSize是一个int

That code is correct. 该代码是正确的。 If that is the code that you are using, you should check whether it is being called. 如果这是您正在使用的代码,则应检查是否正在调用它。 Try putting an NSLog("changing font"); 尝试放置一个NSLog("changing font"); call right before it or something, so you can tell whether or not it is really happening. 在发生问题之前立即致电,这样您就可以判断它是否确实在发生。

A few suggestions, though. 不过有一些建议。 There is probably a more descriptive name for your textview than textView3. 您的textview可能比textView3更具有描述性。 Don't worry about your variable names being too verbose; 不必担心变量名太冗长; believe me, it's a good thing. 相信我,这是一件好事。 Also, if textView3 is an instance variable, you really shouldn't be accessing it directly. 另外,如果textView3是实例变量,则您实际上不应该直接访问它。 Use encapsulation by declaring it as a @property and then @synthesize -ing it. 通过将封装声明为@property ,然后使用@synthesize -ing来使用封装。 Then, your call might look like self.textViewThatDoesSomething.font = … . 然后,您的呼叫可能看起来像self.textViewThatDoesSomething.font = …

Good luck! 祝好运!

Update: I just had another idea. 更新:我有另一个想法。 It may be that your textView3 is not hooked up properly in Interface Builder. 可能是您的textView3在Interface Builder中未正确连接。 Check that and try again. 检查该内容,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM