0

I Want to accomplish the same zoom effect on UICollectionViewCell than Pinterest do.

I read this stack post and try to understand the complex repo.

So I did some lecture about UIViewControllerAnimatedTransitioning.

and to start simple just wanted to move an imageView from firstViewController to the position of the secondViewController's imageView. doesn't care right now about the scale.

so my 2 VC has just 1 imageView at different location. no other subview. and the firstViewController has UIViewControllerTransitioningDelegate with the methods.

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)
    }

  }
}

didn't write all the experimentations that I realized.. but this animation start at 0,0 and is not conform to the SecondViewController's imageView position...

probably need to get the 2nd position maybe before? tried to do it but didn't get more chances..

Community
  • 1
  • 1
raphael
  • 777
  • 1
  • 9
  • 18

1 Answers1

-1

I don't know about your coding but there is a third party control which gives a animation like pinterest.

Below is the link for that

https://github.com/xhzengAIB/PinterestAnimator