ZoomTransitioning
概述
ZoomTransitioning
提供了一个带有图像缩放动画的自定义过渡。当您使用此库与 UINavigationController
一起时,您可以通过边缘滑动来弹出视图控制器。
示例
在Demo目录中运行示例项目,无需运行 carthage update
或 pod install
。
用法
请参阅示例项目的详细信息。
导入 ZoomTransitioning
ZoomTransitionSourceDelegate
适配到源视图控制器
将 extension ImageListViewController: ZoomTransitionSourceDelegate {
func transitionSourceImageView() -> UIImageView {
return selectedImageView
}
func transitionSourceImageViewFrame(forward forward: Bool) -> CGRect {
return selectedImageView.convertRect(selectedImageView.bounds, toView: view)
}
func transitionSourceWillBegin() {
selectedImageView.hidden = true
}
func transitionSourceDidEnd() {
selectedImageView.hidden = false
}
func transitionSourceDidCancel() {
selectedImageView.hidden = false
}
}
ZoomTransitionDestinationDelegate
适配到目标视图控制器
将 extension ImageDetailViewController: ZoomTransitionDestinationDelegate {
func transitionDestinationImageViewFrame(forward forward: Bool) -> CGRect {
if forward {
let x: CGFloat = 0.0
let y = topLayoutGuide.length
let width = view.frame.width
let height = width * 2.0 / 3.0
return CGRect(x: x, y: y, width: width, height: height)
} else {
return largeImageView.convertRect(largeImageView.bounds, toView: view)
}
}
func transitionDestinationWillBegin() {
largeImageView.hidden = true
}
func transitionDestinationDidEnd(transitioningImageView imageView: UIImageView) {
largeImageView.hidden = false
largeImageView.image = imageView.image
}
func transitionDestinationDidCancel() {
largeImageView.hidden = false
}
}
UINavigationController
的 delegate
属性
设置 import ZoomTransitioning
class NavigationController: UINavigationController {
private let zoomNavigationControllerDelegate = ZoomNavigationControllerDelegate()
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
delegate = zoomNavigationControllerDelegate
}
}
要求
- Swift 3.0
- iOS 8.0 或更高版本
如果你使用 Swift 2.2,请使用 1.3.0
安装
Carthage
ZoomTransitioning可以通过Carthage使用。要安装,只需将以下行添加到您的Cartfile中
github "WorldDownTown/ZoomTransitioning"
CocoaPods
ZoomTransitioning可以通过CocoaPods使用。要安装,只需将以下行添加到您的Podfile中
pod 'ZoomTransitioning'
手动
- 下载并将
/ZoomTransitioning
文件夹拖放到您的项目中。 - 恭喜!
作者
WorldDownTown,[email protected]
许可证
ZoomTransitioning遵循MIT许可证。更多信息请参见LICENSE文件。