iOS 开发实用技术导航
NSHipster 中文版
› http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
› http://www.cocos2d-iphone.org/
CocoaPods
› http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
› http://code.google.com/mobile/analytics/
WWDC
› https://developer.apple.com/wwdc/
Design Guides and Resources
› https://developer.apple.com/design/
Transcripts of WWDC sessions
› http://asciiwwdc.com
Cocoa with Love
› http://cocoawithlove.com/
Cocoa Dev Central
› http://cocoadevcentral.com/
NSHipster
› http://nshipster.com/
Style Guides
› Google Objective-C Style Guide
› NYTimes Objective-C Style Guide
Useful Tools and Services
› Charles Web Debugging Proxy
› Smore
georgetso
V2EX  ›  iDev

有个 interactive transition 的问题请教

  •  
  •   georgetso · Jan 20, 2016 · 2512 views
    This topic created in 3969 days ago, the information mentioned may be changed or developed.
    代码地址: http://pan.baidu.com/s/1qX5hV6O

    可以看到,当上下拖动红色的呈现一半的 VC 时,后面白色的 VC 的 alpha 并没有跟着变化。
    为啥?怎么解决?
    Supplement 1  ·  Jan 20, 2016
    下载代码,运行,向下拖动红色的 view controller ,背后白色的 view controller 的 alpha 没有跟着你的动作变化。也就是说 alpha 变化不是 interactive 的,我想知道为啥。
    4 replies  •  2016-01-20 11:46:19 +08:00
    lxian2
    lxian2
    Jan 20, 2016
    1
    没太明白你的问题呀
    georgetso
    georgetso
    OP
    Jan 20, 2016
    2
    @lxian2 下载代码,运行,向下拖动红色的 view controller ,背后白色的 view controller 的 alpha 没有跟着你的动作变化。也就是说 alpha 变化不是 interactive 的,我想知道为啥。
    lxian2
    lxian2
    Jan 20, 2016❤️1
    3
    我认为原因是 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)
    }
    }
    ```
    就可以看到你想要的效果了
    lxian2
    lxian2
    Jan 20, 2016
    4
    vc.modalPresentationStyle = .Custom
    然后这个如果设置成.Custom 的话需要自己实现一个 UIPresentationController
    见 http://stackoverflow.com/questions/24338700/from-view-controller-disappears-using-uiviewcontrollercontexttransitioning/25775726#25775726
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2299 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 13:19 · PVG 21:19 · LAX 05:19 · JFK 08:19
    ♥ Do have faith in what you're doing.