首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Pinterest Like - UIViewControllerAnimatedTransitioning

Pinterest Like - UIViewControllerAnimatedTransitioning
EN

Stack Overflow用户
提问于 2015-09-29 00:31:47
回答 1查看 948关注 0票数 0

我想在UICollectionViewCell上实现和Pinterest一样的缩放效果。

我阅读了这篇stack post,并试图理解复杂的存储库。

所以我做了一些关于UIViewControllerAnimatedTransitioning的讲座。

为了简单起见,我只想将一个imageView从firstViewController移动到第二个firstViewController的imageView的位置。现在并不关心规模。

所以我的2个VC在不同的位置只有1个imageView。没有其他子视图。并且firstViewController具有带有这些方法的UIViewControllerTransitioningDelegate。

代码语言:javascript
复制
class MoveAnimation: NSObject, UIViewControllerAnimatedTransitioning {

  let duration = 2.0

  func transitionDuration(transitionContext: UIViewControllerContextTransitioning) -> NSTimeInterval {
    return duration
  }

  func animateTransition(transitionContext: UIViewControllerContextTransitioning) {

    let containerView = transitionContext.containerView()

    let toVC = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey) as! SecondViewController

    let fromVC = transitionContext.viewControllerForKey(UITransitionContextFromViewControllerKey) as! ViewController

    let toView = toVC.view
    let fromView = fromVC.view

    containerView.addSubview(toView)
    containerView.addSubview(fromView)

    let frame2 = toVC.imageView.frame

    UIView.animateWithDuration(duration, animations: { () -> Void in

      fromVC.imageView.frame = frame2 

      }) { (result) -> Void in
        transitionContext.completeTransition(true)
    }

  }
}

并没有写出我意识到的所有实验..但是这个动画是从0,0开始的,并且不符合SecondViewController的imageView位置...

可能需要在此之前拿到第二名?我试过了,但没有得到更多的机会。

EN

回答 1

Stack Overflow用户

发布于 2015-09-29 00:50:23

我不知道你的代码如何,但是有一个第三方控件可以提供像pinterest这样的动画。

下面是它的链接

https://github.com/xhzengAIB/PinterestAnimator

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32827742

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档