Ali*_*Ali 4 iphone objective-c
我正在更改UIButton字体大小但它不起作用.
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];
Run Code Online (Sandbox Code Playgroud)
我在这段代码中看不到你正在改变字体大小,但无论如何,这可以这样做:
[headingButton.titleLabel setFont:[UIFont fontWithName:<your font name> size:<your desired size>]];
Run Code Online (Sandbox Code Playgroud)
要么
[headingButton.titleLabel setFont:[UIFont fontWithName:systemFontOfSize:<your desired size>]];
Run Code Online (Sandbox Code Playgroud)
更新:此外,您还需要查看应用中是否存在您设置的字体,以便检查是否只有这样:
NSLog(@"Font family names: %@", [UIFont familyNames]);
NSLog(@"Fonts in family Myriad Pro : %@", [UIFont fontNamesForFamilyName:@"Myriad Pro"]);
Run Code Online (Sandbox Code Playgroud)
如果它不存在,你需要将otf文件拖到你的项目中,并在info.plist中添加"由应用程序提供的字体"
| 归档时间: |
|
| 查看次数: |
2377 次 |
| 最近记录: |