设置带边距的最小字体大小UIButton

我找到了解决方案如何设置与我的按钮宽度相对应的最小字体大小:

button.titleLabel.numberOfLines = 1; button.titleLabel.adjustsFontSizeToFitWidth = YES; button.titleLabel.lineBreakMode = NSLineBreakByClipping; 

但是如何在左侧和右侧添加边距。

因此按钮标签的宽度为200 pt,与按钮宽度相同。 我需要我的标题标签与左右两侧的空格,所以这意味着标签宽度必须是180pt,然后我将在右侧和左侧有10pt。

我怎样才能做到这一点?

使用titleEdgeInsets

 button.titleEdgeInsets = UIEdgeInsetsMake(top, left, bottom, right); 

或者特别是在这种情况下:

 button.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 10);