iphone - UIButton 字体大小不变

标签 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]; 

最佳答案

我在这段代码中看不到你正在改变字体大小,但无论如何,这可以这样做:

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

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

更新:此外,您还需要查看您正在设置的字体是否存在于您的应用程序中以检查是否存在:

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

如果不存在,则需要将otf文件拖到你的项目中,并在info.plist中添加“应用程序提供的字体”

关于iphone - UIButton 字体大小不变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6869515/

相关文章:

iphone - [__NSArrayI count]:发送到已释放实例0x6dbfd10的消息

ios - UILabel 不触发 touchesBegan

ios - Objective-C - 在循环后删除/隐藏 NSProgressIndicator

ios - 使 UITableView 行可选择

ios - 如何使用 Mantle 添加与父级的关系?

iphone - 处理 iPhone 5 的较大设备尺寸

ios - 将 DATE 添加到 Xcode xcconfig 文件

ios - 更改 UIView 的边界并让 UICollisionBehavior 对其使用react

ios - 将 RSS 提要中的缩略图图像显示到 tableView 单元格中

objective-c - NSMenuItem 的值与 BOOL 绑定(bind)