传入颜色值生成纯色图片

//通过传入颜色值生成纯色图片
- (UIImage *)imageWithBgColor:(UIColor *)color {
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

导航栏常用属性

1.导航栏背景色设置

self.navigationController.navigationBar.barTintColor = [UIColor greenColor];

2.导航栏标题颜色字体大小

NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
 attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
attrs[NSFontAttributeName] = [UIFont systemFontOfSize:17];
[self.navigationController.navigationBar setTitleTextAttributes:attrs];

3.导航栏左右item

UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStylePlain target:self action:@selector(left)];
self.navigationItem.leftBarButtonItem = leftItem;
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStylePlain target:self action:@selector(right)];   
self.navigationItem.rightBarButtonItem = rightItem;

4.导航栏item字体颜色

self.navigationController.navigationBar.tintColor = [UIColor redColor];
如果要不同item不同颜色,那么item要带一个自定义按钮,再设置按钮属性

5.当前控制器的下一个控制器的返回item去掉文字只保留箭头

 UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(back)];
  self.navigationItem.backBarButtonItem = backItem;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,353评论 25 708
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,245评论 4 61
  • 周末奖赏自己一顿万圣节大餐以及一部《惊天破》,演员们精湛的演技让我口水流一地,而且开启花痴模式,是的,平日里的我可...
    乐言乐语阅读 399评论 0 0
  • 昨夜与一朋友相约聚一聚,我们有好几个月没见了,初见时看她并无什么奇特地方,若非要说那就是她那北方姑娘的身高和那头碎...
    梦游世界阅读 302评论 4 2
  • 还记得前面几年,产品经理这词刚在国内兴起,大家对这一职业还没有清晰认识的时候,就被各媒体以零门槛高回报的宣传口号拿...
    小声讲故事阅读 402评论 0 1