问题
The problem is that UIButton clips title tail (for about 1-2 pixels at the end) when I use italic font like Helvetica Oblique with size bigger than 13. Does anybody know a solution for this problem?
回答1:
Subclass UIButton
class and override setTitle with:
- (void)setTitle:(NSString *)title forState:(UIControlState)state {
[super setTitle:[NSString stringWithFormat:@" %@ ", title] forState:state];
}
This will add additional spaces from both sides of your text. Easy & simple.
回答2:
I had this issue with my script font. Unfortunately there isn't a simple way to fix it. I tried everything and then ended up subclassing UIButton. You can read the details for implementation here: http://blog.tinymission.com/post/subclassing-uibutton
Basically, the easiest thing to do would be to put your own UILabel on top of the UIButton, but for me, that wouldn't work well so I subclassed UIButton.
回答3:
You can set Italic font by setting Uibutton property as
button.titleLabel?.font = UIFont.italicSystemFont(ofSize: 17)
来源:https://stackoverflow.com/questions/6624447/uibutton-italic-font-clipping