Skip to main content
VESDK/iOS/Guides/Overlays/Add Overlays

From App Bundle

VideoEditor SDK supports adding custom overlays from the app bundle. In this example, we add the custom IMG.LY "Grain" overlay.

Load overlay from bundle#

For the custom overlay we construct an Overlay object providing the local resource URL and a display name for our overlay. In addition we set the initial blend mode to hardLight, an exhaustive list of available blend modes can be found in the API docs.

Add overlay to asset catalog#

In order to add the new overlay to our asset catalog, we first add the default items and then append our overlay to the overlays array.

import UIKit
import VideoEditorSDK
class VideoAddOverlaysFromAppBundleSwift: Example, VideoEditViewControllerDelegate {
override func invokeExample() {
// Create a `Video` from a URL to a video in the app bundle.
let video = Video(url: Bundle.main.url(forResource: "Skater", withExtension: "mp4")!)
// Create a custom `Overlay`.
let customOverlay = Overlay(identifier: "imgly_overlay_grain", displayName: "Grain", url: Bundle.main.url(forResource: "imgly_overlay_grain", withExtension: "jpg"), thumbnailURL: nil, initialBlendMode: .hardLight)
// Create a `Configuration` object.
let configuration = Configuration { builder in
// In this example we are using the default assets for the asset catalog as a base.
// However, you can also create an empty catalog as well which only contains your
// custom assets.
let assetCatalog = AssetCatalog.defaultItems
// Add the custom overlay to the asset catalog.
// Use the new asset catalog for the configuration.
builder.assetCatalog = assetCatalog
// Create and present the video editor. Make this class the delegate of it to handle export and cancelation.
let videoEditViewController = VideoEditViewController(videoAsset: video, configuration: configuration)
videoEditViewController.delegate = self
videoEditViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(videoEditViewController, animated: true, completion: nil)
// MARK: - VideoEditViewControllerDelegate
func videoEditViewControllerShouldStart(_ videoEditViewController: VideoEditViewController, task: VideoEditorTask) -> Bool {
// Implementing this method is optional. You can perform additional validation and interrupt the process by returning `false`.
func videoEditViewControllerDidFinish(_ videoEditViewController: VideoEditViewController, result: VideoEditorResult) {
// The user exported a new video successfully and the newly generated video is located at `result.output.url`. Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
func videoEditViewControllerDidFail(_ videoEditViewController: VideoEditViewController, error: VideoEditorError) {
// There was an error generating the video.
// Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)
func videoEditViewControllerDidCancel(_ videoEditViewController: VideoEditViewController) {
// The user tapped on the cancel button within the editor. Dismissing the editor.
presentingViewController?.dismiss(animated: true, completion: nil)