标签:
//通过modal显示一个控制器
[self presentViewControl: animated: completion: {}];
//将控制器隐藏
[self dismissViewControlAnimated: completion:{}];
modal出来的控制器View是从底部钻出来的, 且该控制器是添加到窗口(window)上的
//自己实现Modal效果
//1. 获取window
UIViewController *vc =[ [UIViewController alloc] init];
//2. 将modal 出来的控制器的view添加到窗口上
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
[keyWindow addSubView: vc.view];
//3. 实现从底部转出钻出的动画效果
//注: vc需要强引用(系统modal出来的控制器不需要强引用是因为系统中有一个presentedViewController强引用住当前modal出来的控制器),并且vc是用户自定义的控制器,且向外提供dismissViewController接口
CGRect frame = vc.view.frame;
frame.origin.y = [UIScreen mainScreen].bounds.size.height;
vc.view.frame = frame;
[UIView animationWithDuration:0.5 animations:^{
CGRect frame = vc.view.frame;
frame.origin.y = 0;
vc.view.frame = frame;
}];
标签:
原文地址:http://www.cnblogs.com/skjr/p/5609259.html