Skip to content

Instantly share code, notes, and snippets.

View Xopoko's full-sized avatar

Maksim Kudriavtsev Xopoko

  • Cyprus
View GitHub Profile
@Xopoko
Xopoko / CameraManager.swift
Last active February 18, 2019 03:52
Easily trigger the camera and take a picture with completion.
class CameraManager: NSObject {
static let shared: CameraManager = {
let instance = CameraManager()
return instance
}()
private var completions = [((UIImage?) -> Void, UIImagePickerController)]()
@discardableResult
func present(animated: Bool = true, on viewController: UIViewController? = nil, with completion: @escaping (UIImage?) -> Void) -> UIViewController? {
guard let vc = viewController ?? UIApplication.shared.keyWindow?.rootViewController else {