开发者

UITextView Font not changing

开发者 https://www.devze.com 2023-03-24 15:56 出处:网络
I am using arial font in UITextView but i want to change to Myriad but its not changing textView.font=[UIFont fontWithName:@\"Myria开发者_开发问答d\" size:20];

I am using arial font in UITextView but i want to change to Myriad but its not changing

    textView.font=[UIFont fontWithName:@"Myria开发者_开发问答d" size:20];


Myriad font is not supported by iOS by default, so if you want to use it you'll need to add font file (e.g. *.ttf) to your application resources and make couple of setup steps to make that font visible to system.

Detailed tutorial about how to use custom fonts in iOS application can be found here for example


If You are using XIB and taking IBOutlet ,then select your UITextView and press Command + T to show fonts and change it accordingly. and by the way Myriad font is not supported by iOS by default.

Happy coding...


Use the proper name of font ,for example

textView.font=[UIFont fontWithName:@"Myriad" size:20]; and never set the system font size at that time , when you using the custom font that may create a issue.


Strange behaviour but for textview if you want to change font in code you should first check in storyboard that textview is selectable. If not than it wont change font from code. Strange but thats is true.

Also try this:

Please call all your code in viewDidLoadSubviews method! Than works. I have many problems when chanhing font size, style i viewDidLoad or viewWillApperar methods. So just move your code in viewDidLoadSubviews method. You can use flag to change fonts only once since this method can be called many times :]

0

精彩评论

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