ios 怎么修改navigationitem的颜色

2025-05-07 22:33:47
推荐回答(1个)
回答1:

这个要用自定义的view 才能设置:方法如下
//设置标题

// self.title = @"title1";//修改title 会改变navigationItem。title ,但反之不会,一般设置title用此方法就好了

// self.navigationController.title = @"title2";

//

//自定义标题

// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];

// view.backgroundColor = [UIColor redColor];

UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];

title.text = @"title3";

title.textAlignment = NSTextAlignmentCenter;

title.textColor = [UIColor redColor];

self.navigationItem.titleView = title;