import PhotoEditorSDK
import UIKit
class PhotoAddStickersFromRemoteURLSwift: Example, PhotoEditViewControllerDelegate {
override func invokeExample() {
let photo = Photo(url: Bundle.main.url(forResource: "LA", withExtension: "jpg")!)
let customSticker = Sticker(imageURL: URL(string: "https://img.ly/static/example-assets/custom_sticker_igor.png")!, thumbnailURL: nil, identifier: "custom_sticker_igor")
let existingSticker = Sticker(imageURL: Bundle.imgly.resourceBundle.url(forResource: "imgly_sticker_emoticons_laugh", withExtension: "png")!, thumbnailURL: nil, identifier: "existing_sticker")
let customStickerCategory = StickerCategory(identifier: "custom_sticker_category", title: "Custom", imageURL: URL(string: "https://img.ly/static/example-assets/custom_sticker_igor.png")!, stickers: [customSticker, existingSticker])
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.stickers.append(customStickerCategory)
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)
}
}