如何present出一个透明导航控制器NavigationController + UIVisualEffectView实现模糊效果、毛玻璃效果
2017-04-26 17:58
676 查看
在实际需求中使用模糊效果一般是: 原有界面(保持不变)+ 毛玻璃效果 + 需要展示的界面(上方)。
即:
1.新建工程 ,设置ViewController的背景图(淘宝首页截图),添加按钮及其事件
2在MyTopViewController中添加毛玻璃效果
下载地址:http://download.csdn.net/detail/qq_15509071/9826691
点击打开链接
即:
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
点击打开链接
相关文章推荐
- navigationController push动画 从下往上,类似于presentView的默认动画效果如何实现
- navigationController push动画 从下往上,类似于presentView的默认动画效果如何实现
- presentModalViewController方法,present一个透明的viewController,带动画效果
- 如何实现两个ViewController视图之间的透明效果
- [IOS 开发] 使用UIVisualEffectView实现模糊效果
- 自定义modal一个控制器的效果, presentViewController
- iOS8使用UIVisualEffectView实现模糊效果
- iOS8使用UIVisualEffectView实现模糊效果
- iOS开发之实现模糊效果 Core Image 、 vImage 、UIVisualEffectView、FXBlurView、GPUImage、UIImage+ImageEffects
- 如何在Fragment中使用ViewPager,并实现导航随手势滑动效果
- 在导航控制器的rootviewcontroller中push一个控制器 出现view重叠现象
- 将一个view 的背景设为透明 但view上的图标 不透明 实现类似iphone ipad 主页的滑动效果
- present一个背景透明的viewController
- 安卓自定义View----且看如何巧妙地实现一个类似于电视遥控板的环形按钮效果(上)
- presentViewController 方法中实现半透明背景效果
- UIVisualEffectView用法 毛玻璃效果
- Multiple-View ViewPager-如何实现Viewpager控件的一个页面展示多个page以及回弹效果
- present 一个透明的viewController
- iOS8 中 UIVisualEffectView 模糊效果的使用
- swift-教你如何实现导航上的UISearchController动画效果。