IOS改变导航栏标题颜色

来源:互联网 发布:au软件录音保存 编辑:程序博客网 时间:2024/05/16 15:14
//直接用系统的
//设置导航栏的标题    self.navigationItem.title=@"选择奖励对象";    //设置字体大小和颜色    [self.navigationController.navigationBar setTitleTextAttributes:  @{NSFontAttributeName:[UIFont systemFontOfSize:18],    NSForegroundColorAttributeName:[UIColor whiteColor]}];

自己定制的

//自定义标题视图UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 44)];titleLabel.backgroundColor = [UIColor grayColor];titleLabel.font = [UIFont boldSystemFontOfSize:20];titleLabel.textColor = [UIColor greenColor];titleLabel.textAlignment = NSTextAlignmentCenter;titleLabel.text = @"标题";self.navigationItem.titleView = titleLabel;


0 0