IOS 设置导航栏

时间:2021-11-07 03:10:21

//设置导航栏的标题

self.navigationItem setTitle:@"我的标题";

//设置导航条标题属性:字体大小/字体颜色……

/*设置头的属性:setTitleTextAttributes*/

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];

//初始化导航条右按钮

/*设置文字与调用方法一个UIBarButtonItem*/

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"更多成绩" style:UIBarButtonItemStylePlain target:self action:@selector(mustResults)];

//初始化导航条左按钮

/*设置一张图片 与 文字 返回一个UIBarButtonItem*/

self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"compose_locatebutton_succeeded" title:@"更多成绩" target:self action:@selector(mustResults)];