如何present出一个透明导航控制器NavigationController + UIVisualEffectView实现模糊效果、毛玻璃效果
来源:互联网 发布:淘宝开店交保证金流程 编辑:程序博客网 时间:2024/06/05 21:53
在实际需求中使用模糊效果一般是: 原有界面(保持不变)+ 毛玻璃效果 + 需要展示的界面(上方)。
即:
1.新建工程 ,设置ViewController的背景图(淘宝首页截图),添加按钮及其事件
- (void)viewDidLoad { [super viewDidLoad]; _imageView.frame = [UIScreen mainScreen].bounds; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.backgroundColor = [UIColor orangeColor]; btn.frame = CGRectMake(10, SCREEN_HEIGHT_NEW - 60, SCREEN_WIDTH_NEW - 10 * 2, 40); [self.view addSubview:btn]; [btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside]; [btn setTitle:@"点击展示模糊" forState:UIControlStateNormal]; }- (void)click:(UIButton*)btn{ MyTopViewController *topVC = [[MyTopViewController alloc]init]; UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:topVC]; //present出一个透明导航控制器NavigationController navi.modalPresentationStyle = UIModalPresentationCustom; [self presentViewController:navi animated:YES completion:^{}]; }
2在MyTopViewController中添加毛玻璃效果
- (void)viewDidLoad { [super viewDidLoad]; //只有透明才能看到下方界面 self.view.backgroundColor = [UIColor clearColor]; //实现模糊效果 UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]]; visualEffectView.frame = self.view.bounds; visualEffectView.alpha = 0.88; [self.view addSubview:visualEffectView]; UITextField *textFiled = [[UITextField alloc]initWithFrame:CGRectMake(20, 200, SCREEN_WIDTH_NEW - 20*2, 40)]; [self.view addSubview:textFiled]; textFiled.placeholder = @"请输入手机号"; textFiled.tintColor = [UIColor purpleColor];; textFiled.layer.borderWidth = 1; textFiled.layer.borderColor = [UIColor purpleColor].CGColor; UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.backgroundColor = [UIColor orangeColor]; btn.frame = CGRectMake(10, 170 + 100, SCREEN_WIDTH_NEW - 10 * 2, 50); [btn setTitle:@"下一步" forState:UIControlStateNormal]; [self.view addSubview:btn]; [btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside]; }-(void)click{ UIViewController *vc = [[UIViewController alloc]init]; vc.view.backgroundColor = [UIColor grayColor]; [self.navigationController pushViewController:vc animated:YES];}
下载地址:http://download.csdn.net/detail/qq_15509071/9826691
点击打开链接
0 0
- 如何present出一个透明导航控制器NavigationController + UIVisualEffectView实现模糊效果、毛玻璃效果
- 模糊视图(毛玻璃效果) - UIVisualEffectView
- iOS 8 模糊视图(毛玻璃效果)的简单实现UIVisualEffectView
- iOS8中用UIVisualEffectView实现高斯模糊视图(毛玻璃效果)
- iOS8中用UIVisualEffectView实现高斯模糊视图(毛玻璃效果)
- iOS8 模糊视图(毛玻璃效果) UIVisualEffectView
- iOS_8_API:UIVisualEffectView (毛玻璃效果)
- UIVisualEffectView用法 毛玻璃效果
- 如何实现模糊(毛玻璃)效果
- UIVisualEffectView 毛玻璃效果的应用
- iOS8 的毛玻璃效果(UIVisualEffectView)
- iOS8使用UIVisualEffectView实现模糊效果
- iOS8使用UIVisualEffectView实现模糊效果
- [IOS 开发] 使用UIVisualEffectView实现模糊效果
- iOS8使用UIVisualEffectView实现模糊效果
- iOS 8.0 毛玻璃效果利用UIVisualEffectView快速实现
- 导航栏透明 毛玻璃效果iOS
- 如何实现毛玻璃效果
- POJ 3175 Finding Bovine Roots
- Catalan Square----卡特兰数
- 在ogg中手动同步数据遇到列映射的情况
- 基于 rbd nbd 的支持抢锁的 rbd docker volume plugin
- 字节流操作媒体文件
- 如何present出一个透明导航控制器NavigationController + UIVisualEffectView实现模糊效果、毛玻璃效果
- 苹果ios用js的Date()出现NaN问题解决办法
- 五分钟学GIS | BIM与三维GIS的融合
- JS数据类型
- 百度地图实现最简单的路径规划
- Mybits-generator 自动生成文件
- Mac一键删除所有数据
- Struts2开山篇【引入Struts、自定义MyStruts框架】
- 数据驱动决策的13种思维