2012-12-11 192 views
0

我在我的应用程序添加自定义的字体和我设置自定义字体对于某些按钮按分分级的自定义字体,在厦门国际银行自定义字体集完美UIButton的自定义字体问题

enter image description here

但在设备中执行时,字体自动调整到所有按钮的上方。

enter image description here

这里是我的自定义字体子类代码。

@interface ButtonWithBebasNeueFont : UIButton 
@end 
@implementation ButtonWithBebasNeueFont 

- (void)awakeFromNib 
{ 
    [super awakeFromNib]; 
    self.titleLabel.font = [UIFont fontWithName:@"BebasNeue" size:self.titleLabel.font.pointSize]; 

}

@end 

请指引我来解决这个问题。

谢谢。

回答

1

你看到的问题是字体的ascender属性太小的结果。你有两个选择:

  1. 编辑字体来源直接(解释here)按钮
  2. 设置标题边缘插图像这样:

    self.titleEdgeInsets = UIEdgeInsetsMake(TOP, LEFT, BOTTOM, RIGHT); 
    

与刚刚替补TOP, LEFT, BOTTOM, RIGHT您值。