CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.
TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Oct 2016 |
SPMSupports SPM | ✗ |
Maintained by Wei Zhao.
Viewing a single image using transition animation. Supporting presentation and push & pop.
The simplest way to install this library is to copy Classes/*.swift
to your project.
These properties is global and applied to the whole project.
/// The viewer style. Defaults to Presentation
public var viewerStyle = CPImageViewerStyle.presentation
/// The image of animation image view
public var image: UIImage?
/// The title of *navigationItem.rightBarButtonItem* when viewerStyle is Push
public var rightBarItemTitle: String?
/// The image of *navigationItem.rightBarButtonItem* when viewerStyle is Push
public var rightBarItemImage: UIImage?
/// The action of *navigationItem.rightBarButtonItem* when viewerStyle is Push
public var rightAction: ((Void) -> (Void))?
It’s very easy to use CPImageViewer.
Firstly, conforming to CPImageControllerProtocol protocol and initializing the animationImageView or assigning it an image view.
class ViewController: UIViewController, ImageControllerProtocol {
var animationImageView: UIImageView!
}
override func viewDidLoad() {
animationImageView = UIImageView()
animationImageView.frame = <#frame#>
animationImageView.image = <#image#>
self.view.addSubview(animationImageView)
}
Then, presenting the CPImageViewerViewController
let controller = CPImageViewerViewController()
controller.transitioningDelegate = CPImageViewerAnimator()
controller.image = animationImageView.image
self.presentViewController(controller, animated: true, completion: nil)
or pushing the CPImageViewerViewController
override func viewDidLoad() {
self.navigationController?.delegate = CPImageViewerAnimator()
}
let controller = CPImageViewerViewController()
controller.viewerStyle = .push
controller.image = animationImageView.image
controller.title = "CPImageViewer"
self.navigationController?.pushViewController(controller, animated: true)
Released under the MIT license. See LICENSE for details.