【发布时间】:2014-11-29 21:00:37
【问题描述】:
是否可以自定义 UITableView 中删除按钮的字体?
【问题讨论】:
标签: ios objective-c uitableview fonts
是否可以自定义 UITableView 中删除按钮的字体?
【问题讨论】:
标签: ios objective-c uitableview fonts
不妨看看this question
您可以使用具有所需字体的图像,然后将按钮设置为该图像。如果您使用不同的语言可能会出现问题
【讨论】:
UITableViewCell的删除按钮使用系统字体。因此,如果您想更改应用中的系统字体,只需覆盖 -systemFontOfSize:(CGFloat)fontSize:
创建类别UIFont+System并将此代码放入.m中
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
+ (UIFont *)systemFontOfSize:(CGFloat)fontSize {
return [UIFont fontWithName:@"NameOfYourFont" size:fontSize];
}
#pragma clang diagnostic pop
【讨论】:
你可以利用
UIButton * buttonAppearance = [UIButton appearanceWhenContainedInInstancesOfClasses:@[[YourCustomCell class]]];
[buttonAppearance setAttributedTitle: attributedString forState: UIControlStateNormal];
注意:这会将标题设置为单元格中的所有按钮。然后,您可以根据需要进行更改。
【讨论】: