PhotoEditViewController
@available(iOS 9.0, *)
@objcMembers
@objc(PESDKPhotoEditViewController)
open class PhotoEditViewController : ViewController
A PhotoEditViewController
is the main starting point for the SDK. It displays the rendered
photo and a menu. It can present PhotoEditToolController
objects and react to changes. It
can be presented on its own (thus displaying a toolbar for navigation at the bottom) or be
embedded into a UINavigationController
(thus using the navigation controller’s navigation bar
for navigation).
-
The associated flow controller for this photo edit view controller.
Declaration
Swift
open private(set) var flowController: MainFlowController!
-
The contained
MenuViewController
that displays the menu at the bottom.Declaration
Swift
public let menuViewController: MenuViewController<MenuDataSource<PhotoEditMenuItem>, PhotoEditCellConfigurator>
-
The contained
PhotoEditPreviewController
that displays the preview.Declaration
Swift
public let photoEditPreviewController: PhotoEditPreviewController
-
The container view that the
MenuViewController
‘s view is added to. It does not include thetoolbar
.Declaration
Swift
open private(set) lazy var containerView: UIView { get set }
-
The toolbar of this view controller.
Declaration
Swift
open private(set) lazy var toolbar: Toolbar { get set }
-
The
ToolbarItem
for this view controller.Declaration
Swift
open var toolbarItem: ToolbarItem
-
The configuration object that configures this editor.
Declaration
Swift
public let configuration: Configuration
-
The
UndoController
associated with this photo edit view controller. This instance is automatically passed to the tool controllers.Declaration
Swift
open lazy var undoController: UndoController { get set }
-
The
AssetManager
that this view controller can use to set and get assets.Declaration
Swift
public let assetManager: AssetManager
-
An object that acts as the delegate.
Declaration
Swift
open weak var delegate: PhotoEditViewControllerDelegate?
-
Whether the user made any changes to the photo.
Declaration
Swift
open var hasChanges: Bool { get }
-
Serializes all currently applied operations and the original into a single file, which may be restored on other platforms to continue editing.
Declaration
Swift
@available(*, deprecated, message: "Use `serializedSettings(withImageData:﹚` instead.") open var serializedSettings: Data? { get }
-
Serializes all currently applied operations into a single file, which may be restored on other platforms to continue editing.
Declaration
Swift
open func serializedSettings(withImageData includeImageData: Bool) -> Data?
Parameters
includeImageData
Whether or not to include the base64 encoded JPEG image within the generated image.
Return Value
The serialized settings.
-
Creates a new
PhotoEditViewController
for the given photo data, the given configuration, menu items and photo edit model.Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:menuItems:photoEditModel:﹚` instead.") public convenience init?(data: Data, configuration: Configuration = Configuration(), menuItems: [PhotoEditMenuItem] = PhotoEditMenuItem.defaultItems, photoEditModel: PhotoEditModel = PhotoEditModel())
Parameters
data
The data object should represent an image either in JPG or PNG format. Use this initializer to preserve EXIF data.
configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.
-
Creates a new
PhotoEditViewController
for the givenUIImage
, the given configuration, menu items and photo edit model.Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:menuItems:photoEditModel:﹚` instead.") public convenience init(photo: UIImage, configuration: Configuration = Configuration(), menuItems: [PhotoEditMenuItem] = PhotoEditMenuItem.defaultItems, photoEditModel: PhotoEditModel = PhotoEditModel())
Parameters
photo
The photo to edit. Passing an
UIImage
will not preserve EXIF data.configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.
-
Creates a new
PhotoEditViewController
for the givenUIImage
, the givenData
if notnil
, the given configuration, menu items and photo edit model. If noData
object is passed, theUIImage
object will be used and no EXIF data is preserved. If aData
object is passed however, the passedUIImage
will only be used for the preview, but the actual data will be used from theData
object, thus preserving EXIF data.Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:menuItems:photoEditModel:﹚` instead.") public convenience init(photo: UIImage, data: Data?, configuration: Configuration, menuItems: [PhotoEditMenuItem], photoEditModel: PhotoEditModel)
Parameters
photo
The photo to edit.
data
The photo as a
Data
object. The object should represent an image either in JPG or PNG format.configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.
-
Creates a new
PhotoEditViewController
for the givenPhoto
, the given configuration, menu items and photo edit model.Declaration
Swift
public required init(photoAsset: Photo, configuration: Configuration = Configuration(), menuItems: [PhotoEditMenuItem] = PhotoEditMenuItem.defaultItems, photoEditModel: PhotoEditModel = PhotoEditModel())
Parameters
photoAsset
The photo to edit.
configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.
-
The undo button that is displayed in the editor.
Declaration
Swift
open private(set) var undoButton: OverlayButton?
-
The redo button that is displayed in the editor.
Declaration
Swift
open private(set) var redoButton: OverlayButton?
-
All overlay buttons that are displayed in the editor. This includes
undoButton
andredoButtton
.Declaration
Swift
open private(set) var overlayButtons: [OverlayButton]
-
Presents the tool that is represented by the given
ToolMenuItem
. You must only call this when the editor is already on-screen.Declaration
Swift
open func presentTool(for toolMenuItem: ToolMenuItem)
Parameters
toolMenuItem
The tool menu item whose represented tool should be presented.
-
Applies all changes to the high resolution image and calls the delegate methods.
Declaration
Swift
open func renderHighResolutionImage()
-
The tools that are currently on the stack.
Declaration
Swift
open private(set) var viewControllers: [PhotoEditToolController]
-
Pushes a new tool onto the tool stack and presents its view.
Declaration
Swift
@objc(pushViewController:animated:completion:) open func push(_ viewController: PhotoEditToolController, animated: Bool, completion: (() -> Void)? = nil)
Parameters
viewController
The tool controller to present.
animated
Whether to show this tool animated or not.
completion
A closure that is executed after the presentation animation is finished.
-
Pops the top view controller from the stack and removes its view.
Declaration
Swift
@discardableResult @objc(popViewControllerAnimated:completion:) open func pop(animated: Bool, completion: (() -> Void)? = nil) -> PhotoEditToolController?
Parameters
animated
Whether to animate the transition or not.
completion
A closure that is executed after the dismissal animation.
Return Value
The tool that was popped from the stack, if any.
-
The photo edit model.
Declaration
Swift
open var photoEditModel: PhotoEditModel { get set }
-
Creates a new
PhotoEditViewController
for the given photo data and the given configuration, using the default menu items and photo edit model.Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:﹚` instead.") public convenience init?(data: Data, configuration: Configuration)
Parameters
data
The data object should represent an image either in JPG or PNG format. Use this initializer to preserve EXIF data.
configuration
The configuration options to apply.
-
Creates a new
PhotoEditViewController
for the given photo data, the given configuration, menu items and photo edit model.Attention
This initializer should only be used with Objective-C.
Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:menuItems:photoEditModel:﹚` instead.") public convenience init?(data: Data, configuration: Configuration, menuItems: [_ObjCPhotoEditMenuItem], photoEditModel: _ObjCPhotoEditModel)
Parameters
data
The data object should represent an image either in JPG or PNG format. Use this initializer to preserve EXIF data.
configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.
-
Creates a new
PhotoEditViewController
for the givenUIImage
and the given configuration, using the default menu items and photo edit model.Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:﹚` instead.") public convenience init(photo: UIImage, configuration: Configuration)
Parameters
photo
The photo to edit. Passing an
UIImage
will not preserve EXIF data.configuration
The configuration options to apply.
-
Creates a new
PhotoEditViewController
for the givenUIImage
, the given configuration, menu items and photo edit model.Attention
This initializer should only be used with Objective-C.
Declaration
Swift
@available(*, deprecated, message: "Use `init(photoAsset:configuration:menuItems:photoEditModel:﹚` instead.") public convenience init(photo: UIImage, configuration: Configuration, menuItems: [_ObjCPhotoEditMenuItem], photoEditModel: _ObjCPhotoEditModel)
Parameters
photo
The photo to edit. Passing an
UIImage
will not preserve EXIF data.configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.
-
Creates a new
PhotoEditViewController
for the givenPhoto
and the given configuration, using the default menu items and photo edit model.Declaration
Swift
public convenience init(photoAsset: Photo, configuration: Configuration)
Parameters
photoAsset
The photo to edit.
configuration
The configuration options to apply.
-
Creates a new
PhotoEditViewController
for the givenPhoto
, the given configuration, menu items and photo edit model.Attention
This initializer should only be used with Objective-C.
Declaration
Swift
public convenience init(photoAsset: Photo, configuration: Configuration, menuItems: [_ObjCPhotoEditMenuItem], photoEditModel: _ObjCPhotoEditModel)
Parameters
photoAsset
The photo to edit.
configuration
The configuration options to apply.
menuItems
The menu items to display.
photoEditModel
The initial photo edit model to apply to the photo.