1
lxian2 2016-01-20 10:49:24 +08:00
没太明白你的问题呀
|
2
georgetso OP @lxian2 下载代码,运行,向下拖动红色的 view controller ,背后白色的 view controller 的 alpha 没有跟着你的动作变化。也就是说 alpha 变化不是 interactive 的,我想知道为啥。
|
3
lxian2 2016-01-20 11:45:03 +08:00 1
我认为原因是 dismiss 的时候 animateTransition 里面没有设置 transitionContext.containerView()
改成 ``` if let toVC = toVC, toView = toVC.view, fromVC = fromVC, fromView = fromVC.view { if isPresenting { var frame = transitionContext.initialFrameForViewController(fromVC) frame.origin.y = frame.size.height toView.frame = frame transitionContext.containerView()?.addSubview(toView) } else { toView.frame = transitionContext.finalFrameForViewController(toVC) fromView.frame = transitionContext.initialFrameForViewController(fromVC) print(toView.frame, fromView.frame) transitionContext.containerView()?.addSubview(toView) transitionContext.containerView()?.addSubview(fromView) toView.alpha = 0.5 toView.transform = CGAffineTransformMakeScale(0.98, 0.98) } } ``` 就可以看到你想要的效果了 |
4
lxian2 2016-01-20 11:46:19 +08:00
vc.modalPresentationStyle = .Custom
然后这个如果设置成.Custom 的话需要自己实现一个 UIPresentationController 见 http://stackoverflow.com/questions/24338700/from-view-controller-disappears-using-uiviewcontrollercontexttransitioning/25775726#25775726 |