Skip to main content
PESDK/iOS/Guides
Language:

Configuration

PhotoEditor SDK can be flexibly customized to meet your requirements. Configuration options are generally subdivided into global and screen specific options, for example configuring the global background of all views or setting the color of a button in the camera view.

A Configuration class contains all global and nested configurations belonging to a specific view. Its default properties are set in the constructor and are read-only. In order to set up our configuration object we make use of a builder pattern by passing a closure that takes a builder object as an argument through which properties can be set.

Global Configuration#

Global configuration options can be set as properties on the builder objects. Here, we are configuring the menu and background color of the entire editor.

View-Specific Configuration#

In order to modify view-specific options we invoke the corresponding view controllers configure method configure*ViewController on the builder and pass a closure that takes the options as an argument. In this example, we set the crop ratio of the camera to square and display the cancel button.

Configuring UI Elements using Closures#

If we want to customize the UI elements of a specific view, we can do so by setting a certain element's configuration closure. Inside this closure we have access to a mutable instance of the element. Here, we are setting the cameraRollButtonConfigurationClosure in order to configure the border and color of the camera roll button.

For further customization options of the user interface consult the user interface section of the guides.

File:
import PhotoEditorSDK
import UIKit
class ConfigurationExampleSwift: Example {
override func invokeExample() {
let configuration = Configuration { builder in
builder.theme.backgroundColor = UIColor.white
builder.theme.menuBackgroundColor = UIColor.lightGray
builder.configureCameraViewController { options in
options.showCancelButton = true
options.cropToSquare = true
options.cameraRollButtonConfigurationClosure = { button in
button.layer.borderWidth = 2.0
button.layer.borderColor = UIColor.red.cgColor
}
}
}
let cameraViewController = CameraViewController(configuration: configuration)
cameraViewController.cancelBlock = { [weak self] in
self?.presentingViewController?.dismiss(animated: true)
}
cameraViewController.modalPresentationStyle = .fullScreen
presentingViewController?.present(cameraViewController, animated: true, completion: nil)
}
}