Common

  • Use this class to initialize the SDK from your App Delegate. For example:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    
       PixelSDK.setup("YOUR API KEY")
    
       return true
    }
    

    An API key can be generated here. Keep your API key private.

    If you do not provide an API key or it is invalid, the VideoExporter and ImageExporter will export with a watermark.

    Additionally, this class is used for global settings like primaryFilters. Further SDK customization is handled by individual controllers and sessions.

    See more

    Declaration

    Swift

    @objcMembers
    public class PixelSDK
  • The ContainerController view consists of a tab bar at the bottom and a controller above it. Each tab is represented by a ContainerMode with an associated controller and title for the tab. The tab bar can be customized by initializing this controller with the modes of your choosing.

    If you initialize a ContainerController with only one mode, the tab bar will be automatically hidden.

    See more

    Declaration

    Swift

    @objcMembers
    public class ContainerController : UIViewController
  • The LibraryController offers a way to quickly select and crop images or videos from the users Photo Library. Users can switch between regular albums, smart albums, iCloud albums, or albums imported directly from a DSLR camera. In addition, there is a separate section for selecting and deleting drafts.

    Figure 1 Library controller

    Screenshot

    This controller is used inside the ContainerController and can be used on its own by initializing the container controller with only one mode .library.

    For more information on modifying the cropping behavior of the library controller see its PreviewCropController.

    The library controller can also be restricted to only display certain types of media. For example images only:

    containerController.libraryController.fetchPredicate = NSPredicate(format: "mediaType == %d", PHAssetMediaType.image.rawValue)
    containerController.libraryController.draftMediaTypes = [.image]
    

    By default, the library controller pushes an EditController onto the navigation stack when the Next button is pressed. This can be disabled by setting showsEditControllerWhenDone to false. You will also need to implement the LibraryControllerDelegate in order to respond the libraryController(_:didFinishWithSession:withSegment:) delegate method.

    See more

    Declaration

    Swift

    @objcMembers
    public class LibraryController : UIViewController
  • The CameraController can take photos with low UI latency and Vine style video while also applying realtime filters. Filters can be applied by swiping left or right in the camera view, or by pressing the filters button. The filters can be changed with the primaryFilters variable.

    Figure 1 Camera controller

    Screenshot

    This controller is used inside the ContainerController and can be used on its own by initializing the container controller with only one mode .photo or .video.

    The camera can be restricted to produce only content of a specific aspect ratio. For example square content:

    container.cameraController.aspectRatio = CGSize(width: 1, height: 1)
    

    By default, the camera controller pushes an EditController onto the navigation stack after a photo or video is taken. This can be disabled by setting showsEditControllerWhenDone to false. You will also need to implement the CameraControllerDelegate in order to respond the cameraController(_:didFinishWithSession:) delegate method.

    See more

    Declaration

    Swift

    @objcMembers
    public class CameraController : UIViewController
  • The primary functionality of the EditController includes filter selection, filter intensity, adjustments (brightness, vibrance, saturation, etc.), cropping, rotation, horizontal/vertical perspective correction, and video segment composing/trimming/re-ordering.

    The edit controller is always presented with an image or video based Session object. Sessions can be edited programmatically by changing filters, crop rects, trim times and more. The edit controller will display all programmatic changes to a session in its interface. For more information on modifying a session see the Session documentation.

    When presented with an image based session, the controller consists of two tabs Filter and Adjust. When presented with a video, the controller consists of three tabs Filter, Trim and Adjust. You may edit media of any aspect ratio. All editing functionality available to images is also available to videos.

    Normally the edit controller is pushed onto the navigation stack by either the LibraryController or CameraController. You may also present the edit controller manually with a Session for example:

    let image = UIImage(named: "test_image")!
    
    let session = Session(image: image)
    
    let editController = EditController(session: session)
    editController.delegate = self
    
    let nav = UINavigationController(rootViewController: editController)
    nav.modalPresentationStyle = .fullScreen
    self.present(nav, animated: true, completion: nil)
    

    Attention

    Sessions are automatically saved so you a responsible for calling destroy() when you are done with a session (unless noted otherwise). If you do not destroy a session it will persist in the users Drafts in memory and on disk.

    You may also present an edit controller with one or more AVAssets, for example:

    let asset1 = AVAsset(url: Bundle.main.url(forResource: "test", withExtension: "mov")!)
    let asset2 = AVAsset(url: Bundle.main.url(forResource: "test2", withExtension: "mp4")!)
    
    let _ = Session(assets: [asset1, asset2], sessionReady: { (session, error) in
        guard let session = session else {
            print("Unable to create session: \(error!)")
            return
        }
    
        let editController = EditController(session: session)
        editController.delegate = self
    
        let nav = UINavigationController(rootViewController: editController)
        nav.modalPresentationStyle = .fullScreen
        self.present(nav, animated: true, completion: nil)
    })
    

    Filters under the Filter or Adjust tabs may be changed by setting the primaryFilters adjustmentFilters variables respectively.

    The Adjust tab places the Position (cropping) button before the adjust filters. Cropping can be disabled by setting showsPositionAdjustment to false.

    See more

    Declaration

    Swift

    @objcMembers
    public class EditController : UIViewController