标题显示3个点“…”而不是切换button中的string

奇怪的行为。 我试图做切换button,改变button的标题。 但不是“完成”它显示我“…”:

在这里输入图像说明

方法:

-(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]; } } 

它被截断,无论button需要更大,还是文本需要更小。

要dynamic调整文本,

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

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

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