Present Single Lens in Camera Kit
Overview
In your Camera Kit integration, sometimes you only want to show a single Lens vs showing all your Lenses in the group. If you are not using your own custom layout then below guide should help you achieve this on iOS.
iOS Implementation
There are two ways to have a single Lens in an iOS integration. The first way is to apply a lens programmatically without any carousel. You may prefer to do it this way if your app does not require the user to select between several Lenses. The second way optionally selects a Lens of your choosing inside the carousel. This may be preferred if you would like to preserve the Lens icon on the Carousel or if you would like the user to choose among different options. Both ways are illustrated through modifications of Snap’s iOS sample app.
Presenting a single Lens without the UI
To apply a lens programmatically and remove the UI elements replace CameraViewController.cameraController(_:updatedLenses:)
with the following:
open func cameraController(_ controller: CameraController, updatedLenses lenses: [Lens]) {
// 1. Add lenses programmatically
if let lens: Lens = cameraController.cameraKit.lenses.repository.lens(
id: "YOUR-LENS-ID",
groupID: "YOUR-GROUP-ID") {
applyLens(lens)
}
//2. Remove UI elements
cameraView.carouselView.isHidden = true
cameraView.carouselView.isUserInteractionEnabled = false
cameraView.cameraActionsView.isHidden = true
cameraView.cameraActionsView.isUserInteractionEnabled = false
cameraView.messageView.isHidden = true
}
As you can see, the various UI elements are found in CameraView
. They are public and therefore removable from the UI.