I'm trying to replace the default iOS device rotation animation on my UIcollectionView. I'm using viewWillTransitionToSize and the targetTransform() on the transitionCoordinator to prevent the default view rotation, and then use a transform to rotate each visibleCell into the correct orientation. It works fine, except:
Here’s my implementation of ViewWillTransitionTosize :
override func viewWillTransitionToSize( size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator){
super.viewWillTransitionToSize(size , withTransitionCoordinator: coordinator)
let transf : CGAffineTransform = coordinator.targetTransform()
let invertedRotation = CGAffineTransformInvert(transf)
let currentBounds = view.bounds
coordinator.animateAlongsideTransition({
_ in
self.view.transform = CGAffineTransformConcat(self.view.transform, invertedRotation )
self.undoRotation = CGAffineTransformConcat(self.undoRotation, transf)
self.view.bounds = currentBounds
}, completion: ({ finished in
if ( finished != nil){
UIView.animateWithDuration(0.5, animations: {
for cell in self.collectionView!.visibleCells(){
cell.contentView.transform = self.undoRotation
}
})}
})
)
Here a quick gif. to ilustrate the problem: http://www.blessinglopes.com/Info
Any Help will be greatly appreciated! Thank you!
I have solved the problem by implementing a separate thread in which the cell is animated. You can check out the code in the git repository below.