Я хочу добиться того же эффекта масштабирования в UICollectionViewCell, что и Pinterest.
Я прочитал этот сообщение стека и попытался понять сложное репо.
Итак, я прочитал лекцию об UIViewControllerAnimatedTransitioning.
и для начала просто хотел переместить imageView из firstViewController в положение imageView второгоViewController. сейчас не волнует масштаб.
поэтому у моих 2 VC есть только 1 imageView в другом месте. нет другого подвида. а у firstViewController есть UIViewControllerTransitioningDelegate с методами.
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 и не соответствует позиции imageView SecondViewController...
наверное нужно получить 2 позицию может раньше? пытался сделать это, но не получил больше шансов ..