设置透明的NavBar 获取纯色图片
2015-12-06 10:44
615 查看
设置透明的NavBar 获取纯色图片
import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor cyanColor]; ////获取纯色图片的方法 UIImage *image = [self imageWithColor:[[UIColor blackColor] colorWithAlphaComponent:0.15]]; ////设置NavBar的背景图片 [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault]; ////去除阴影分割线的方法 [self.navigationController.navigationBar setShadowImage:image]; self.navigationController.navigationBar.translucent = YES; } ////获取一个纯色的图片 - (UIImage *)imageWithColor:(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; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } @end
相关文章推荐
- booststrap中的navbar
- 深入理解BootStrap Item11 -- 导航页(navbar)
- 自定义NavgationBa返回按钮
- 怎么让self.view的Y从navigationBar下面开始计算
- 关于Android4.4以后沉浸式自定义状态栏实现
- Bootstrap组件学习笔记(三)——导航
- 微信小程序之-----简单的navbar
- bootstrap——组件(六、导航条)
- Bootstrap 3.3.7学习笔记13
- 设置navigationbar及状态栏颜色
- vue tab组件
- iOS中Navbar设置渐变色效果的方法示例
- Bootstrap Navbar Component实现响应式导航
- 微信小程序 navbar实例详解
- 解决bootstrap导航栏navbar在IE8上存在缺陷的方法
- 全面解析Bootstrap中form、navbar的使用方法
- 导航条
- HTML5技术分享angular开发应用实现
- Pycharm上Django的使用 Day13
- 【笔记】《Bootstrap实战》——第3章 WordPress主题【自】