Skip to content

rosberry/CroppingRCam

Repository files navigation

CroppingRCam

Swift Version Carthage Compatible Swift Package Manager

Using

Initialization CroppingRCamCoordinator

    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
    }
  1. ModalStyleDecorator - It is view controller wrapper that allows to provide action buttons for modal presentation.
  2. 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 value nil.
  1. delegate: CroppingRCamDelegate - needed for handle event on CroppingRCamCoordinator.
// 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
    }
}

Show CroppingRCam

    @objc private func openCroppingRCamController() {
        // 1
        croppingRCamCoordinator?.rCamCustomizationHandler = { rCamViewController in
            rCamViewController.view.backgroundColor = .brown
        }
        // 2
        croppingRCamCoordinator?.pushCameraViewController(isAnimated: true)
    }
  1. Use handler if need customization rCamViewController.
  2. About CroppingRCamCoordinator use func pushCameraViewController and push on Camera VC.

Requirements

  • iOS 11.0+
  • Xcode 11.0+

Installation

Carthage

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

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'

Swift Package Manager

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"))
]

Documentation

Read the docs. Generated with jazzy. Hosted by GitHub Pages.

About

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.

License

This project is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published