iOS透明viewControler
来源:互联网 发布:手机照片排版软件 编辑:程序博客网 时间:2024/06/01 08:52
有时候在跳转控制器的时候需要,跳转到当前控制器上方,显示一个可以看到下方原来控制器的半透明控制器。
如下图:
跳转方式可以修改这句代码来实现,激变,从下往上。或者也可以自定义一些动画。(已经被我注释掉的那些)
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
跳转的时候根据要跳转到哪一层控制器上方的情况,修改如下代码
[self.tabBarController presentViewController:controller animated:YES completion:nil] (这里是跳转到tabBar控制器的上方。)
第一个控制器代码
#import "ViewController.h"#import "MKDialogController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.// fade //交叉淡化过渡(不支持过渡方向)// push //新视图把旧视图推出去// moveIn //新视图移到旧视图上面// reveal //将旧视图移开,显示下面的新视图// cube //立方体翻滚效果// oglFlip //上下左右翻转效果// suckEffect //收缩效果,如一块布被抽走(不支持过渡方向)// rippleEffect //滴水效果(不支持过渡方向)// pageCurl //向上翻页效果// pageUnCurl //向下翻页效果// cameraIrisHollowOpen //相机镜头打开效果(不支持过渡方向)// cameraIrisHollowClose //相机镜头关上效果(不支持过渡方向)}- (IBAction)btnClick:(UIButton *)sender { MKDialogController *controller = [[MKDialogController alloc] init]; controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) { controller.providesPresentationContextTransitionStyle = YES; controller.definesPresentationContext = YES; controller.modalPresentationStyle = UIModalPresentationOverCurrentContext;// CATransition *animation = [CATransition animation];// animation.duration = 2.0;// animation.timingFunction = UIViewAnimationCurveEaseInOut;// animation.type = @"cameraIrisHollowOpen";//// animation.subtype = kCATransitionFromLeft;// [self.view.window.layer addAnimation:animation forKey:nil]; [self.tabBarController presentViewController:controller animated:YES completion:nil]; } else { self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext; [self presentViewController:controller animated:NO completion:nil]; self.view.window.rootViewController.modalPresentationStyle = UIModalPresentationFullScreen; }}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
要跳转的控制器代码
#import "MKDialogController.h"@interface MKDialogController ()@end@implementation MKDialogController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColor clearColor]; UIView *alphaView = [[UIView alloc] initWithFrame:self.view.frame]; UIView *baseView = [[UIView alloc] initWithFrame:self.view.frame]; alphaView.backgroundColor = [UIColor clearColor]; baseView.backgroundColor = [UIColor blackColor]; baseView.alpha = 0.8; [self.view addSubview:baseView]; [self.view addSubview:alphaView]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; button.frame = CGRectMake(20, 178, 100, 60); [button setTitle:@"点我返回" forState:UIControlStateNormal]; button.backgroundColor = [UIColor brownColor]; [alphaView addSubview:button]; [button addTarget:self action:@selector(dissmiss) forControlEvents:UIControlEventTouchUpInside];}- (void)dissmiss{ [self dismissViewControllerAnimated:YES completion:nil];}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.}*/@end
1 0
- iOS透明viewControler
- iOS开发之ViewControler
- ios多个ViewControler页面切换
- ios 设置UITableViewcell透明
- IOS TableViewCell 透明背景
- IOS-透明NavigationBar
- iOS ViewController透明化
- iOS 透明视图控制器
- iOS navigationBar背景透明
- ios UIWebView 背景透明
- iOS导航栏透明
- IOS 创建透明UIViewController
- iOS 组透明
- ios导航栏透明
- ios 导航栏透明
- ios 透明导航栏
- iOS NavigationBar设置透明
- iOS navigation 透明处理
- linux svn迁移备份的三种方法
- C++--------检测电脑是否休眠过
- java 运行堆内存分析
- OC用字典数组创建省市区
- Delphi中调用API函数经验点滴(二)
- iOS透明viewControler
- C#中常用的几种读取XML文件的方法
- C++权限继承方式对权限的影响
- Java 类加载器
- 游戏开发令人拍案叫绝的小网站收藏
- ClassLoader 学习
- Json概述以及python对json的基本操作
- linux:centos gcc 升级 gcc-4.8.1
- iOS button图片与文字互换