import PhotoEditorSDK
import UIKit
class PhotoAddOverlaysFromAppBundleSwift: Example, PhotoEditViewControllerDelegate {
override func invokeExample() {
let photo = Photo(url: Bundle.main.url(forResource: "LA", withExtension: "jpg")!)
let customOverlay = Overlay(identifier: "imgly_overlay_grain", displayName: "Grain", url: Bundle.main.url(forResource: "imgly_overlay_grain", withExtension: "jpg"), thumbnailURL: nil, initialBlendMode: .hardLight)
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.overlays.append(customOverlay)
builder.assetCatalog = assetCatalog
}
let photoEditViewController = PhotoEditViewController(photoAsset: photo, configuration: configuration)
photoEditViewController.delegate = self
photoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(photoEditViewController, animated: true, completion: nil)
}
func photoEditViewControllerShouldStart(_ photoEditViewController: PhotoEditViewController, task: PhotoEditorTask) -> Bool {
true
}
func photoEditViewControllerDidFinish(_ photoEditViewController: PhotoEditViewController, result: PhotoEditorResult) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
func photoEditViewControllerDidFail(_ photoEditViewController: PhotoEditViewController, error: PhotoEditorError) {
print(error.localizedDescription)
presentingViewController?.dismiss(animated: true, completion: nil)
}
func photoEditViewControllerDidCancel(_ photoEditViewController: PhotoEditViewController) {
presentingViewController?.dismiss(animated: true, completion: nil)
}
}