UIButton上的标题截断

时间:2011-12-07 17:57:26

标签: objective-c ios uibutton uinavigationbar

我已将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;

enter image description here

1 个答案:

答案 0 :(得分:1)

 [button setFrame:CGRectMake(0, 0, 250, 40)];  // are you sure your button is wide enough?