@@ -23,7 +23,7 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
23
23
private let kDeltaBetweenCellLayers : Int ! = 2
24
24
25
25
//MARK :- UIViewControllerAnimatedTransitioning
26
- func transitionDuration( transitionContext: UIViewControllerContextTransitioning ) -> NSTimeInterval {
26
+ func transitionDuration( transitionContext: UIViewControllerContextTransitioning ? ) -> NSTimeInterval {
27
27
return animationDuration
28
28
}
29
29
@@ -34,7 +34,12 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
34
34
35
35
let fromViewController = transitionContext. viewControllerForKey ( UITransitionContextFromViewControllerKey) !
36
36
let toViewController = transitionContext. viewControllerForKey ( UITransitionContextToViewControllerKey) !
37
- let container = transitionContext. containerView ( )
37
+ //let container = transitionContext.containerView()
38
+
39
+ guard let container = transitionContext. containerView ( ) else {
40
+ assertionFailure ( " containerView is nil " )
41
+ return
42
+ }
38
43
39
44
container. backgroundColor = UIColor . clearColor ( )
40
45
@@ -126,7 +131,7 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
126
131
127
132
private func addAnimationsToDestinationCollectionView( destinationCollectionViewController: UICollectionViewController , sourceCollectionViewController: UICollectionViewController , toViewController: UIViewController ) {
128
133
129
- let indexPaths : NSArray = sourceCollectionViewController. collectionView!. indexPathsForSelectedItems ( )
134
+ let indexPaths : NSArray = sourceCollectionViewController. collectionView!. indexPathsForSelectedItems ( ) !
130
135
let selectedCellIndex : NSIndexPath = indexPaths. firstObject as! NSIndexPath
131
136
let selectedCell = sourceCollectionViewController. collectionView!. cellForItemAtIndexPath ( selectedCellIndex) !
132
137
@@ -139,11 +144,11 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
139
144
140
145
let rowsAndColumns = destinationCollectionViewController. collectionView!. numberOfVisibleRowsAndColumn ( )
141
146
142
- if let indexPathsForVisibleCells = destinationCollectionViewController. collectionView? . indexPathsForVisibleItems ( ) as? Array < NSIndexPath > {
147
+ if let indexPathsForVisibleCells = destinationCollectionViewController. collectionView? . indexPathsForVisibleItems ( ) {
143
148
144
- let indexPaths = indexPathsForVisibleCells. sorted ( { $0. row < $1. row } )
149
+ let indexPaths = indexPathsForVisibleCells. sort ( { $0. row < $1. row } )
145
150
146
- for (idx , index) in enumerate ( indexPaths ) {
151
+ for (_ , index) in indexPaths . enumerate ( ) {
147
152
148
153
if let cell = destinationCollectionViewController. collectionView? . cellForItemAtIndexPath ( NSIndexPath ( forRow: index. row, inSection: index. section) ) {
149
154
@@ -162,8 +167,8 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
162
167
//temporary change cell color to selected cell background color
163
168
cell. backgroundColor = fromCellColor
164
169
165
- var source = sourceCollectionViewController. collectionView
166
- var destination = destinationCollectionViewController. collectionView
170
+ let source = sourceCollectionViewController. collectionView
171
+ let destination = destinationCollectionViewController. collectionView
167
172
168
173
if let fromFlowLayout = source? . collectionViewLayout as? UICollectionViewFlowLayout ,
169
174
toFlowLayout = destination? . collectionViewLayout as? UICollectionViewFlowLayout ,
@@ -174,7 +179,7 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
174
179
cell. alpha = 1.0
175
180
cell. layer. zPosition = kTopCellLayerZIndex - CGFloat( cellIndexPath. row*self. kDeltaBetweenCellLayers)
176
181
177
- UIView . animateKeyframesWithDuration ( 1.0 , delay: 0 , options: UIViewKeyframeAnimationOptions . allZeros , animations: { ( ) -> Void in
182
+ UIView . animateKeyframesWithDuration ( 1.0 , delay: 0 , options: UIViewKeyframeAnimationOptions ( ) , animations: { ( ) -> Void in
178
183
179
184
let relativeStartTime = ( self . kCellAnimBigDelta*Double ( cellIndexPath. row % rowsAndColumns. columns) )
180
185
@@ -217,11 +222,11 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
217
222
218
223
private func setNewFrameToCells( destinationCollectionViewController: UICollectionViewController) {
219
224
220
- if let destinationIndexPathsForVisibleCells = destinationCollectionViewController. collectionView? . indexPathsForVisibleItems ( ) as? Array < NSIndexPath > {
225
+ if let destinationIndexPathsForVisibleCells = destinationCollectionViewController. collectionView? . indexPathsForVisibleItems ( ) {
221
226
222
- let sortedIndexPaths = destinationIndexPathsForVisibleCells. sorted ( { $0. row < $1. row } )
227
+ let sortedIndexPaths = destinationIndexPathsForVisibleCells. sort ( { $0. row < $1. row } )
223
228
224
- for ( idx , index) in enumerate ( sortedIndexPaths ) {
229
+ for ( _ , index) in sortedIndexPaths . enumerate ( ) {
225
230
226
231
if let cell = destinationCollectionViewController. collectionView? . cellForItemAtIndexPath ( index) ,
227
232
@@ -237,15 +242,15 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
237
242
238
243
assert ( destinationCollectionViewController. selectedIndexPath != nil , " Forgot to set selectedIndexPath property? " )
239
244
240
- var sourceIndexPathsForVisibleCells = sourceCollectionViewController. collectionView? . indexPathsForVisibleItems ( ) as? Array < NSIndexPath >
241
- sourceIndexPathsForVisibleCells!. sort ( { $0. row < $1. row } )
245
+ var sourceIndexPathsForVisibleCells = sourceCollectionViewController. collectionView? . indexPathsForVisibleItems ( )
246
+ sourceIndexPathsForVisibleCells = sourceIndexPathsForVisibleCells !. sort ( { $0. row < $1. row } )
242
247
243
248
let rowsAndColumns = destinationCollectionViewController. collectionView!. numberOfVisibleRowsAndColumn ( )
244
249
245
- for ( idx, index) in enumerate ( sourceIndexPathsForVisibleCells!. reverse ( ) ) {
250
+ for ( idx, index) in sourceIndexPathsForVisibleCells!. reverse ( ) . enumerate ( ) {
246
251
247
252
if let cell = sourceCollectionViewController. collectionView? . cellForItemAtIndexPath ( index) ,
248
- layoutAttributes = sourceCollectionViewController. collectionView? . layoutAttributesForItemAtIndexPath ( index) ,
253
+ _ = sourceCollectionViewController. collectionView? . layoutAttributesForItemAtIndexPath ( index) ,
249
254
lastSelectedCell = destinationCollectionViewController. collectionView? . cellForItemAtIndexPath ( destinationCollectionViewController. selectedIndexPath) ,
250
255
flowLayout = destinationCollectionViewController. collectionView? . collectionViewLayout as? UICollectionViewFlowLayout {
251
256
@@ -275,7 +280,7 @@ class CKWaveCollectionViewAnimator: NSObject, UIViewControllerAnimatedTransition
275
280
relativeDuration = self . animationDuration - relativeStartTime
276
281
}
277
282
278
- UIView . animateKeyframesWithDuration ( self . animationDuration, delay: 0 , options: UIViewKeyframeAnimationOptions . allZeros , animations: { ( ) -> Void in
283
+ UIView . animateKeyframesWithDuration ( self . animationDuration, delay: 0 , options: UIViewKeyframeAnimationOptions ( ) , animations: { ( ) -> Void in
279
284
280
285
UIView . addKeyframeWithRelativeStartTime ( 0.0 + ( self . kCellAnimSmallDelta * Double( cellIndex) ) , relativeDuration: self . animationDuration - ( self . kCellAnimSmallDelta * Double( cellIndex) ) , animations: { ( ) -> Void in
281
286
0 commit comments