我已将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;
答案 0 :(得分:1)
[button setFrame:CGRectMake(0, 0, 250, 40)]; // are you sure your button is wide enough?