1. 程式人生 > >iOS修改導航條title字型顏色

iOS修改導航條title字型顏色

1、第一種方法

self.title = @"title";

[self.navigationController.navigationBarsetTitleTextAttributes:

@{NSFontAttributeName:[UIFontsystemFontOfSize:19],

NSForegroundColorAttributeName:[UIColorredColor]}];

1、第二種方法

//自定義標題檢視

    UILabel *navTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 40)];

    navTitleLabel.backgroundColor

= [UIColor blackColor];

    navTitleLabel.font = [UIFont boldSystemFontOfSize:25];

    navTitleLabel.textColor = [UIColor greenColor];

    navTitleLabel.textAlignment = NSTextAlignmentCenter;

    navTitleLabel.text = @"title";

self.navigationItem.titleView = navTitleLabel;