在开发中经常会用到导航器,在导航器中添加标题很简单,如下:

self.title=@"Elimination phase Day 1";

但是如果题目太长,后半部分就变成省略号了,那要实现自定义字体,代码和效果如下:

image

 

 

 

UILabel *titleText = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, 200, 20)]; 
    titleText.backgroundColor = [UIColor clearColor]; 
    [titleText setFont:[UIFont systemFontOfSize:15.0]]; 
    [titleText setText:@"Elimination phase Day 1"]; 
    self.navigationItem.titleView=titleText; 
    [titleText release];