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

标签 ios objective-c

奇怪的行为。我正在尝试制作更改按钮标题的切换按钮。 但它显示的不是“完成”,而是“...”:

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

最佳答案

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

要动态调整文本,

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

关于ios - 标题显示 3 个点 "..."而不是切换按钮中的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22425356/

相关文章:

ios - Objective-C/CocoaHTTPServer - 是否可以将响应返回到应用程序?

ios - 设备未断开连接

ios - 超过 1 个 AdbannerViews

ios - 如果找到匹配正则表达式,则从字符串中获取值

ios - TableView 不会从 Parse.com 重新加载数据

ios - API流程阻塞图和交互

iOS - Facebook 登录 检查登录状态

ios - 更新xcode版本9.0.1时遇到问题

objective-c - respondsToSelector - 不工作

iphone - 如何捕获UIView中CG内容的触摸事件?