Dav*_*123 4 fonts objective-c font-size uilabel
我有一个问题,我允许用户在我的项目中为标签选择字体,但是当用户设置该标签的大小(使用不同的按钮)时,标签将重置为默认字体.我希望能够保留用户已应用的字体,同时仍允许用户更改字体大小.任何帮助表示赞赏,谢谢!
这是我的代码..
-(IBAction)setFont{
[userText setFont:[UIFont fontWithName:@"Arial-BoldMT" size:50.0]];
//I had to add a size when setting the font or else I got an error
}
-(IBAction)setFontSize{
[userText setFont:[UIFont systemFontOfSize:24]];
}
Run Code Online (Sandbox Code Playgroud)
rma*_*ddy 27
只需fontWithSize:在标签的当前字体上使用该方法:
- (IBAction)setFontSize {
// Keep the same font but change its size to 24 points.
UIFont *font = userText.font;
userText.font = [font fontWithSize:24];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11141 次 |
| 最近记录: |