@@ -37,7 +37,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
3737
3838 // MARK: - UIViewControllerAnimatedTransition Protocol
3939
40- public func transitionDuration( transitionContext: UIViewControllerContextTransitioning ) -> NSTimeInterval {
40+ public func transitionDuration( transitionContext: UIViewControllerContextTransitioning ? ) -> NSTimeInterval {
4141 if interactive {
4242 return 0.7
4343 }
@@ -63,21 +63,21 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
6363
6464 assert ( fromView != nil && toView != nil , " fromView and toView need to be set " )
6565
66- var container = self . transitionContext!. containerView ( ) ;
66+ let container = self . transitionContext!. containerView ( ) ;
6767
6868 // add toViewController to Transition Container
6969 if let view = toViewController? . view {
7070 if ( isPresenting) {
71- container. addSubview ( view)
71+ container? . addSubview ( view)
7272 } else {
73- container. insertSubview ( view, belowSubview: fromViewController!. view)
73+ container? . insertSubview ( view, belowSubview: fromViewController!. view)
7474 }
7575 }
7676 toViewController? . view. layoutIfNeeded ( )
7777
7878 // Calculate animation frames within container view
79- fromFrame = container. convertRect ( fromView!. bounds, fromView: fromView)
80- toFrame = container. convertRect ( toView!. bounds, fromView: toView)
79+ fromFrame = container? . convertRect ( fromView!. bounds, fromView: fromView)
80+ toFrame = container? . convertRect ( toView!. bounds, fromView: toView)
8181
8282 // Create a copy of the fromView and add it to the Transition Container
8383 if let imageView = fromView as? UIImageView {
@@ -90,7 +90,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
9090 view. clipsToBounds = true
9191 view. frame = fromFrame!
9292 view. contentMode = fromView!. contentMode
93- container. addSubview ( view)
93+ container? . addSubview ( view)
9494 }
9595
9696 if ( isPresenting) {
@@ -124,7 +124,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
124124 toView? . hidden = true
125125 fromView? . alpha = 0 ;
126126
127- var duration = transitionDuration ( transitionContext!)
127+ let duration = transitionDuration ( transitionContext!)
128128 UIView . animateWithDuration ( duration, delay: 0 , usingSpringWithDamping: 0.8 , initialSpringVelocity: 0 , options: UIViewAnimationOptions . CurveLinear, animations: { ( ) -> Void in
129129
130130 self . toViewController? . view. alpha = 1
@@ -158,7 +158,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
158158 fromView? . alpha = 0 ;
159159 let duration = transitionDuration ( transitionContext!)
160160
161- UIView . animateWithDuration ( duration, delay: 0 , usingSpringWithDamping: 0.8 , initialSpringVelocity: 0 , options: nil , animations: { ( ) -> Void in
161+ UIView . animateWithDuration ( duration, delay: 0 , usingSpringWithDamping: 0.8 , initialSpringVelocity: 0 , options: [ ] , animations: { ( ) -> Void in
162162 self . fromViewController? . view. alpha = 0
163163 if ( self . interactive == false ) {
164164 self . transitionView? . frame = self . toFrame!
@@ -192,8 +192,6 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
192192 // MARK: - Gesture Recognizer Handlers
193193
194194 func handlePinchGesture( gesture: UIPinchGestureRecognizer ) {
195- var view = gesture. view!
196-
197195 switch ( gesture. state) {
198196 case . Began:
199197 interactive = true ;
@@ -231,7 +229,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
231229 // calculate current scale of transitionView
232230 let finalScale = animationFrame!. width / self . fromFrame!. size. width
233231 let currentScale = ( transitionView!. frame. size. width / self . fromFrame!. size. width)
234- var delta = finalScale - currentScale
232+ let delta = finalScale - currentScale
235233 var normalizedVelocity = gesture. velocity / delta
236234
237235 // add upper and lower bound on normalized velocity
@@ -249,7 +247,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
249247
250248 let duration = transitionDuration ( transitionContext!)
251249
252- UIView . animateWithDuration ( duration, delay: 0 , usingSpringWithDamping: 1 , initialSpringVelocity: normalizedVelocity, options: UIViewAnimationOptions . allZeros , animations: { ( ) -> Void in
250+ UIView . animateWithDuration ( duration, delay: 0 , usingSpringWithDamping: 1 , initialSpringVelocity: normalizedVelocity, options: UIViewAnimationOptions ( ) , animations: { ( ) -> Void in
253251
254252 // set a new transform to reset the rotation to 0 but maintain the current scale
255253 self . transitionView? . transform = CGAffineTransformMakeScale ( currentScale, currentScale)
@@ -271,8 +269,6 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
271269 }
272270
273271 func handleRotationGesture( gesture: UIRotationGestureRecognizer ) {
274- var view = gesture. view!
275-
276272 if interactive {
277273 if gesture. state == UIGestureRecognizerState . Changed {
278274 transitionView!. transform = CGAffineTransformRotate ( transitionView!. transform, gesture. rotation)
@@ -282,7 +278,7 @@ public class ZoomTransition: UIPercentDrivenInteractiveTransition, UIViewControl
282278 }
283279
284280 func handlePanGesture( gesture: UIPanGestureRecognizer ) {
285- var view = gesture. view!
281+ let view = gesture. view!
286282
287283 if interactive {
288284 if gesture. state == UIGestureRecognizerState . Changed {
0 commit comments