       snapshotView.addSubview(subSnapshotView!)
     }
     
-    let snapshotWithShadowView = addShadow(toView: snapshotView, reverse: left)
+    let snapshotWithShadowView = addShadow(to: snapshotView, reverse: left)
     containerView?.addSubview(snapshotWithShadowView)
     axesValues = valuesForAxe(initialValue: left ? 0.0 : 1.0, reverseValue: 0.5)
     snapshotWithShadowView.layer.anchorPoint = CGPoint(x: axesValues.0, y: axesValues.1)
     return snapshotWithShadowView
   }
   
-  func addShadow(toView view: UIView, reverse: Bool) -> UIView {
+  func addShadow(to view: UIView, reverse: Bool) -> UIView {
     let viewWithShadow = UIView(frame: view.frame)
     let shadowView = UIView(frame: viewWithShadow.bounds)
     let gradient = CAGradientLayer()

    size = toView.frame.size
    foldSize = width * 0.5 / CGFloat(folds)

    let viewFolds = createSnapshots(toView: toView, fromView: fromView, containerView: containerView)
    animateFoldTransition(fromView: fromView, toViewFolds: viewFolds[0], fromViewFolds: viewFolds[1], completion: {
      if !transitionContext.transitionWasCancelled {
        toView.frame = containerView.bounds


private extension FoldAnimator {
  
  func makeSnapshots(toView: UIView, fromView: UIView, containerView: UIView) -> [[UIView]] {
    var fromViewFolds = [UIView]()
    var toViewFolds = [UIView]()
    for i in 0..<folds {
      let offset = CGFloat(i) * foldSize * 2
      let leftFromViewFold = makeSnapshot(from: fromView, afterUpdates: false, offset: offset, left: true)
      var axesValues = valuesForAxe(initialValue: offset, reverseValue: height / 2)
      leftFromViewFold.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
      fromViewFolds.append(leftFromViewFold)
      leftFromViewFold.subviews[1].alpha = 0.0

      let rightFromViewFold = makeSnapshot(from: fromView, afterUpdates: false, offset: offset + foldSize, left: false)
      axesValues = valuesForAxe(initialValue: offset + foldSize * 2, reverseValue: height / 2)
      rightFromViewFold.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
      fromViewFolds.append(rightFromViewFold)
      rightFromViewFold.subviews[1].alpha = 0.0

      let leftToViewFold = makeSnapshot(from: toView, afterUpdates: true, offset: offset, left: true)
      axesValues = valuesForAxe(initialValue: self.reverse ? width : 0.0, reverseValue: height / 2)
      leftToViewFold.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
      axesValues = valuesForAxe(initialValue: 0.0, reverseValue: 1.0)
      leftToViewFold.layer.transform = CATransform3DMakeRotation(.pi * 2, axesValues.0, axesValues.1, 0.0)
      toViewFolds.append(leftToViewFold)

      let rightToViewFold = makeSnapshot(from: toView, afterUpdates: true, offset: offset + foldSize, left: false)
      axesValues = valuesForAxe(initialValue: self.reverse ? width : 0.0, reverseValue: height / 2)
      rightToViewFold.layer.position = CGPoint(x: axesValues.0, y: axesValues.1)
      axesValues = valuesForAxe(initialValue: 0.0, reverseValue: 1.0)
