[英]UIButton Custom font issue
I have added a custom font in to my application and i set that custom font for some of the buttons by sub classing the custom font,in xib custom font set perfectly 我在我的应用程序中添加了自定义字体,并通过将自定义字体子类化为xib自定义字体,来为某些按钮设置该自定义字体
but while execute in device the font auto adjust to upside in all the button. 但是在设备中执行时,字体会自动调整为在所有按钮上都向上。
Here is my custom font sub class code. 这是我的自定义字体子类代码。
@interface ButtonWithBebasNeueFont : UIButton
@end
@implementation ButtonWithBebasNeueFont
- (void)awakeFromNib
{
[super awakeFromNib];
self.titleLabel.font = [UIFont fontWithName:@"BebasNeue" size:self.titleLabel.font.pointSize];
} }
@end
Please guide me to fix this issue. 请指导我解决此问题。
Thanks. 谢谢。
The problem you're seeing is a result of the font's ascender property being too small. 您看到的问题是字体的ascender属性太小的结果。 You have two options:
您有两种选择:
Set the title edge insets of the button like so: 设置按钮的标题边缘插图,如下所示:
self.titleEdgeInsets = UIEdgeInsetsMake(TOP, LEFT, BOTTOM, RIGHT);
Just substitute TOP, LEFT, BOTTOM, RIGHT
with your values. 只需将
TOP, LEFT, BOTTOM, RIGHT
替换为您的值即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.