开发者

UIButton font Size Not Changing

I am changing UIButton f开发者_运维问答ont size but it does not effect.

UIButton*headingButton=[UIButton buttonWithType:UIButtonTypeCustom];

headingButton.frame=CGRectMake(182, 4, 450, 42);        

[headingButton setTitleColor:[UIColor colorWithRed:36/255.0 green:71/255.0 blue:113/255.0 alpha:1.0] forState:UIControlStateNormal]; 


I cant see in this code that u are changing font size but anyway, this can be done like so:

[headingButton.titleLabel setFont:[UIFont fontWithName:<your font name> size:<your desired size>]];

or

[headingButton.titleLabel setFont:[UIFont fontWithName:systemFontOfSize:<your desired size>]];

Update: plus you also need to see if the font u are setting exists in your app to check just do this:

NSLog(@"Font family names: %@", [UIFont familyNames]);
NSLog(@"Fonts in family Myriad Pro : %@", [UIFont fontNamesForFamilyName:@"Myriad Pro"]);

If it doesnt exist, you need to drag the otf file into ur project and also add the "Fonts provided by application" in info.plist


 btn.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:8.0];

 btn.titleLabel.font =  [UIFont boldSystemFontOfSize:btn.titleLabel.font.pointSize+3];

first Line for set font name and size and second line for bold a font

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜