private var croppingRCamCoordinator: CroppingRCam?
override func viewDidLoad() {
super.viewDidLoad()
// 1
let decorator = ModalStyleDecorator()
guard let navigationController = navigationController else {
return
}
// 2
self.croppingRCamCoordinator = CroppingRCam(decorator: decorator, navigationController: navigationController)
// 3
croppingRCamCoordinator?.delegate = self
}ModalStyleDecorator- It is view controller wrapper that allows to provide action buttons for modal presentation.- Initialization CroppingRCamCoordinator:
init(decorator: Decorator,
navigationController: UINavigationController?,
rCamCustomizationHandler: ((CameraViewController) -> Void)? = nil,
cropCustomizationHandler: ((CropperViewController) -> Void)? = nil)decorator: ModalStyleDecorator- It is view controller wrapper that allows to provide action buttons for modal presentation.navigationController: UINavigationViewController- navigation controller.rCamCustomizationHandler and cropCustomizationHandler- needed for customization controller. Default valuenil.
delegate: CroppingRCamDelegate- needed for handle event onCroppingRCamCoordinator.
// MARK: - CroppingRCamDelegate
extension ViewController: CroppingRCamDelegate {
func croppingRCam(_ coordinator: CroppingRCam, imageCaptured image: UIImage) {
// Triggered afler cropped on image
}
func croppingRCamClosedEventTriggered(_ coordinator: CroppingRCam) {
// Triggered after make photo
}
func croppingRCamBackEventTriggered(_ coordinator: CroppingRCam) {
// Triggered after tap close on RCamViewController
}
} @objc private func openCroppingRCamController() {
// 1
croppingRCamCoordinator?.rCamCustomizationHandler = { rCamViewController in
rCamViewController.view.backgroundColor = .brown
}
// 2
croppingRCamCoordinator?.pushCameraViewController(isAnimated: true)
}- Use handler if need customization rCamViewController.
- About
CroppingRCamCoordinatorusefunc pushCameraViewControllerand push on Camera VC.
- iOS 11.0+
- Xcode 11.0+
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate CroppingRCam into your Xcode project using Carthage, specify it in your Cartfile:
github "rosberry/CroppingRCam"
CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate CroppingRCam into your Xcode project using CocoaPods, specify it in your Podfile:
pod 'CroppingRCam'The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. Once you have your Swift package set up, adding CroppingRCam as a dependency is as easy as adding it to the dependencies value of your Package.swift.
dependencies: [
.package(url: "https://github.com/rosberry/CroppingRCam.git", .upToNextMajor(from: "1.0.0"))
]Read the docs. Generated with jazzy. Hosted by GitHub Pages.
This project is owned and maintained by Rosberry. We build mobile apps for users worldwide 🌏.
Check out our open source projects, read our blog or give us a high-five on 🐦 @rosberryapps.
This project is available under the MIT license. See the LICENSE file for more info.
