Skip to main content
PESDK/iOS/Guides/Stickers

Custom Stickers

PhotoEditor SDK for iOS allows extension of predefined sticker categories by implementing a custom sticker view controller

Custom sticker view controller#

Predefined sticker categories can be extended by providing a custom view controller that is automatically added to the view hierarchy when selecting the appropriate custom category. The view controller instance must be exposed by an object conforming to StickerCollection protocol.

The selected sticker can then be added to the canvas by calling the StickerCollectionDelegate.

The sticker will be stored in the personal sticker category. It will also be embedded in the serialization if it was not removed from the canvas before the export.

class CustomStickerController: UIViewController, StickerCollection {
var viewController: UIViewController { self }
weak var delegate: StickerCollectionDelegate?
// Add custom views
func someAction() {
delegate?.stickerCollection(self, didSelect: Sticker(imageURL: URL(string: "https://sample.image")!, thumbnailURL: URL(string: "https://sample.thumbnail")!, identifier: UUID().uuidString))
}
}

A custom category can be added to the existing categories in a familiar way. Instead of passing a stickers array, you should provide a stickerCollection object.

let previewURL = Bundle.main.url(forResource: "custom_controller", withExtension: "png")!
let customStickerCategory = StickerCollectionCategory(title: "Custom Controller", imageURL: previewURL, stickerCollection: CustomStickerController())
let configuration = Configuration { builder in
let assetCatalog = AssetCatalog.defaultItems
assetCatalog.stickers.append(customStickerCategory)
builder.assetCatalog = assetCatalog
}

Consult the next section to learn how to use external APIs such as image search engines as a data source for your custom sticker categories.