我正在测试以下代码:

username = @"addagkagalkjagjalggxxaklgjagjglkjag";

NSString *fullUsername = [NSString stringWithFormat:@"%@%@", @"@", username];

UIButton *usernameButton = [UIButton buttonWithType:UIButtonTypeSystem];
[usernameButton setTitle:fullUsername forState:UIControlStateNormal];

usernameButton.frame = CGRectMake(100.0, 10.0, 215.0, 25.0);

最终结果在标签的中心截断并省略。我最后要它,但是我必须为此设置什么属性?

最佳答案

usernameButton.titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;

09-10 00:37