【问题标题】:Title on a UIButton truncatesUIButton 上的标题被截断
【发布时间】:2011-12-07 17:57:26
【问题描述】:

我已将 UIButton 设置为导航栏的 titleView。然而,无论按钮有多宽,标题似乎都会被截断。为什么?

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:[[NSDate date] stringWithNSDateFormatterMediumStyle] forState:UIControlStateNormal];
[button setFrame:CGRectMake(0, 0, 150, 40)];
self.navigationItem.titleView = button;

【问题讨论】:

    标签: objective-c ios uibutton uinavigationbar


    【解决方案1】:
     [button setFrame:CGRectMake(0, 0, 250, 40)];  // are you sure your button is wide enough?
    

    【讨论】:

    • 当然。不管我让它有多宽,它总是被截断!
    • 我不确定,但这可能是导航栏施加的限制。您可以使用较短的格式,例如 12/25/11 或更小的字体吗?
    • 是的,我最终就是这么做的。
    猜你喜欢
    • 2018-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-07
    • 2013-08-20
    • 2016-07-28
    • 2021-11-17
    • 2016-12-04
    相关资源
    最近更新 更多