美文网首页A知识点2A知识点
iOS开发设置导航栏的背景颜色、标题颜色、字体、大小

iOS开发设置导航栏的背景颜色、标题颜色、字体、大小

作者: lczalh | 来源:发表于2017-08-22 18:56 被阅读111次

//设置导航栏的背景颜色

UINavigationBar *bar = [UINavigationBar appearance];

 bar.barTintColor = [UIColor colorWithRed:62/255.0 green:173/255.0 blue:176/255.0 alpha:1.0];

//设置导航栏title字体类型和大小

[self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:@"Helvetica-Bold" size:22],NSForegroundColorAttributeName:[UIColor whiteColor],}];


设置导航条背景图片时有时self.view会向下偏移64像素

//此句代码解决坐标问题

[self.navigationController.navigationBar setTranslucent:YES];

//当translucent = YES,controller中self.view的原点是从导航栏左上角开始计算

//当translucent = NO,controller中self.view的原点是从导航栏左下角开始计算

相关文章

网友评论

    本文标题:iOS开发设置导航栏的背景颜色、标题颜色、字体、大小

    本文链接:https://www.haomeiwen.com/subject/waoldxtx.html