希望我能在 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。提前致谢!