-(void)setNaviTiTleByLabel
{
//创建一个label可以调整字体大小,颜色
//必须设置Frame,宽度与高度要设置正确,x,y无论设置为多少都是居中显示,如果不设置Frame整个标题都不会显示,但是如果左面按钮过长,标题会向另一边偏移。
UILabel* label = [[UILabelalloc]initWithFrame:CGRectMake(230,55,50, 44)];
label.text =@"哈哈中国";
label.textColor = [UIColorredColor];
label.font = [UIFontsystemFontOfSize:22];
self.navigationItem.titleView = label;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItemalloc]initWithTitle:@"速度发送地" style:0 target:self action:nil];
}
-(void)setNaviTitleByUIButton
{
//不用设置Frame的值,也是居中显示,但是如果左面按钮过长,标题会向另一边偏移
UIButton* btn = [[UIButtonalloc]init];
[btn setTitle:@"哈哈中国" forState:UIControlStateNormal];
btn.titleLabel.font = [UIFontsystemFontOfSize:19];
[btn setTitleColor:[UIColorblueColor]forState:UIControlStateNormal];
self.navigationItem.titleView = btn;
self.navigationItem.leftBarButtonItem = [[UIBarButtonItemalloc]initWithTitle:@"速度发送地" style:0 target:self action:nil];
}