title从左上角跑到居中的地方
self.navigationItem.titleView = titleLabel;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, height)];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.font = [UIFont systemFontOfSize:16];
titleLabel.text = title;
[titleLabel sizeToFit];
是因为我们要在
- (void)viewDidLoad {} 中赋值title 而不是应该在
- (void)viewWillAppear:(BOOL)animated{} 中赋值
也可以吧title当做参数跳转时传进来 在viewDidLoad 中赋值