开发者

Problem when implementing 'labelFontSize' property

I have been trying to add this code into my project:

reasonLabel.font = [UIFont labelFontSize:15];

but I keep getting this warning:

Class method '+labelWithSize:' not found (return type defaults to 'id')

How would I fix this?

开发者_高级运维

Thanks,

Seb


You can use with

[UIFont fontWithName:@"Arial" size:14]

or

[UIFont systemFontOfSize:14]


[UIFont labelFontSize] returns the standard system UILabel font size, it is not an initializer. You must use something like fontWithSize:(CGFloat)fontSize or systemFontOfSize:(CGFloat)fontSize


Use

reasonLabel.font = [UIFont systemFontOfSize: [UIFont labelFontSize]];

and if you want to create a smaller or bigger font, just add or subtract:

reasonLabel.font = [UIFont systemFontOfSize: [UIFont labelFontSize] + 2];
reasonLabel.font = [UIFont systemFontOfSize: [UIFont labelFontSize] - 1];

For bold fonts use this:

reasonLabel.font = [UIFont boldSystemFontOfSize: [UIFont labelFontSize]];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜