UIButton.titleLabel剪辑文本问题

时间:2010-08-13 18:47:23

标签: objective-c uibutton uilabel clipping

希望我可以通过UILabel的一个相当模糊的问题得到一些帮助。我一直遇到剪辑字符的问题。下面链接图像中的字体是baskerville-bolditalic。黄色是UIButton渲染的矩形。黄色是UIButton的titleLabel.backgroundColor。

http://img5.imageshack.us/img5/2381/screenshot20100813at235.png

以下是代码:

    UIButton * currentCharacter = [UIButton buttonWithType:UIButtonTypeCustom];
    currentCharacter.frame = cFrame;
    currentCharacter.backgroundColor = [UIColor blueColor];
        currentCharacter.titleLabel.backgroundColor = [UIColor yellowColor];
        currentCharacter.titleLabel.numberOfLines = 1;
        currentCharacter.titleLabel.adjustsFontSizeToFitWidth = YES;
        currentCharacter.titleLabel.minimumFontSize = 1;
        currentCharacter.titleLabel.font = currentFont;
        currentCharacter.titleLabel.clipsToBounds = NO;
        currentCharacter.clipsToBounds = NO;

        currentCharacter.titleLabel.textAlignment = UITextAlignmentCenter;
        currentCharacter.titleLabel.adjustsFontSizeToFitWidth = YES;

也许我只是误解了adjustsFontSizeToFitWidth。非常感谢![/ p>

0 个答案:

没有答案