ios - UILabel : how do you set the font size?

如何从 UILabel 设置字体大小?

我的代码:

UILabel *myView = [[UILabel alloc] initWithFrame:RectFrame];
[myView setBackgroundColor:[UIColor blueColor]];
[myView setText:[NSString stringWithFormat:@" A"]];
[myView setFont:[12] ]; <--- Error
[self.view addSubview:myView];

最佳答案

[myView setFont:[UIFont systemFontOfSize:12]];

[myView setFont:[UIFont boldSystemFontOfSize:12]];

或用于字体系列

[myView setFont:[UIFont fontWithName:@"Helvetica" size:12]];

https://stackoverflow.com/questions/6294621/

相关文章:

iphone - 改变 setContentOffset 的速度 :animated:?

objective-c - "Couldn' t 编译连接 :"error mean? 是什么意思

ios - 为什么 UICollectionView 的 UICollectionViewCell

ios - 如何隐藏/显示导航栏中的右键

ios - 显示 UIAlertController 的简单 App Delegate 方法(在 S

objective-c - 如何在 "for (id item in items)" objecti

ios - Xcode 8 中的单元测试失败

objective-c - 是否可以将 NSInteger 转换为 NSNumber?

ios - 如何将 NSDate 转换为相对格式 "Today","Yesterday","a we

objective-c - 核心数据 : error: Failed to call designa