有一些在导航控制器显示的视图,其中有两个title非常长。
导航中超出长度的title字符就会被压缩,显示成……
。
有没有办法能让导航根据标题长度自动调整?
在ViewDidload
中加上下面的代码:
self.title = @"Your TiTle Text";
UILabel* tlabel=[[UILabel alloc] initWithFrame:CGRectMake(0,0, 200, 40)];
tlabel.text=self.navigationItem.title;
tlabel.textColor=[UIColor whiteColor];
tlabel.font = [UIFont fontWithName:@"Helvetica-Bold" size: 30.0];
tlabel.backgroundColor =[UIColor clearColor];
tlabel.adjustsFontSizeToFitWidth=YES;
self.navigationItem.titleView=tlabel;
导航栏上加UILabel,,