CKWaveCollectionViewTransition
这是一个酷炫的自定义过渡效果,可以在两个或更多UICollectionViewControllers之间实现类似于波浪的cell动画。可以用于例如画廊等。
动画灵感来源于Łukasz Frankiewicz的Dribble项目
安装
有两种选择:
- 通过CocoaPods。
- 手动将文件添加到您的Xcode项目中。稍微简单一些,但更新也是手动的。
使用
- 在Storyboard中,向您的NavigationController中添加一个对象。
- 将其类设置为NavigationControllerDelegate
- 将NavigationController代理设置为该对象。
或者
在您的ViewController中实现UINavigationControllerDelegate。
func navigationController(navigationController: UINavigationController, animationControllerForOperation operation: UINavigationControllerOperation,
fromViewController fromVC: UIViewController, toViewController toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
let animator = CKWaveCollectionViewAnimator()
if operation != UINavigationControllerOperation.Push {
animator.reversed = true
}
return animator
}
- 最后要设置的是在didSelectItemAtIndexPath方法实现中设置selectedIndexPath属性。
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
selectedIndexPath = indexPath
}
属性
internal let animationDuration: Double! = 1.0
总动画时长。
internal let kCellAnimSmallDelta: Double! = 0.01
internal let kCellAnimBigDelta: Double! = 0.03
您可以通过更改这些属性来调整动画。
要求
- iOS 7.0+
版权
遵循 MIT 许可证发布。更多信息请参阅 LICENSE 文件。