标题显示3个点“...”而不是切换按钮中的字符串

时间:2014-03-15 14:58:16

标签: ios objective-c

奇怪的行为。我试图制作切换按钮,改变按钮的标题。 但不是" Done"它告诉我" ..." :

enter image description here

方法:

-(IBAction)toggleEditingMode:(id)sender
{
    if(self.isEditing){
        [sender setTitle:@"Edit" forState:UIControlStateNormal];

        [self setEditing:NO animated:YES];
    }
    else if(!self.isEditing){
        [sender setTitle: @"Done" forState:UIControlStateNormal];

        [self setEditing:YES animated:YES];
    }
}

2 个答案:

答案 0 :(得分:3)

它的截断,要么按钮需要更大,要么文本需要更小。

动态调整文字

yourButton.titleLabel.adjustsFontSizeToFitWidth = YES;
yourButton.titleLabel.minimumScaleFactor = 0.5;

答案 1 :(得分:3)

您可以在设置Barberton项后添加此代码。它工作正常。

[[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor clearColor]} forState:UIControlStateNormal];