OverlayController
@objc(IMGLYOverlayController) open class OverlayController: NSObject
An OverlayController
manages all overlays that have been added to an image and hosts the
overlay’s container view.
-
The parent view that the container was added to.
Declaration
Swift
open let parentView: UIView
-
The container view that hosts all overlays.
Declaration
Swift
open let view = UIView()
-
The base image. Needed for some calculations.
Declaration
Swift
open var baseImage: CIImage?
-
The frame and its image that is currently added as an overlay.
Declaration
Swift
open var frame: (Frame, UIImage)?
-
An
UIImage
of the painting to use as an overlay.Declaration
Swift
open var painting: UIImage?
-
The image view that displays the painting.
Declaration
Swift
open private(set) var paintingImageView = UIImageView()
-
The image view that displays the frame.
Declaration
Swift
open private(set) var frameImageView = UIImageView()
-
The undo controller associated with this overlay controller.
Declaration
Swift
open let undoController: UndoController
-
The currently selected overlay.
Declaration
Swift
open var selectedOverlayView: UIView?
-
A handler that should be called when the currently selected overlay changes.
Declaration
Swift
open var selectionChangedHandler: ((_ previousSelection: UIView?, _ newSelection: UIView?) -> Void)?
-
Whether or not any overlays are added.
Declaration
Swift
open var overlaysAdded: Bool
-
Adds a sticker as an overlay.
Declaration
Swift
@discardableResult open func addSticker(_ sticker: Sticker, with image: UIImage, select: Bool, completion: ((UIImageView) -> Void)?) -> UIImageView
Parameters
sticker
The sticker that should be added.
image
The image of the sticker.
select
Whether or not the sticker should be selected after it was added.
completion
A completion handler to run after the sticker was added.
Return Value
The image view that was added.
-
Adds text as an overlay.
Declaration
Parameters
text
The text to add as an overlay.
color
The color of the text.
select
Whether or not the text should be selected after it was added.
completion
A completion handler to run after the sticker was added.
Return Value
The text label that was added.
-
Adds a frame as an overlay.
Declaration
Swift
@objc(addFrame:withImage:) open func addFrame(_ frame: Frame, with image: UIImage)
Parameters
frame
The frame to add to the image.
image
The image to add to the image.
-
Removes the current frame as an overlay.
Declaration
Swift
open func removeFrame()
-
Moves the currently selected overlay to the front.
Declaration
Swift
open func bringSelectedOverlayToFront()
-
Moves the passed overlay to the front.
Declaration
Swift
open func bringOverlay(toFront overlay: UIView)
Parameters
overlay
The overlay to move to the front.
-
Moves the passed overlay to the specified index.
Declaration
Swift
open func moveOverlay(_ overlay: UIView, toIndex index: Int)
Parameters
overlay
The overlay to move.
index
The index to move to.
-
Moves the painting to the front.
Declaration
Swift
open func bringPaintingToFront()
-
Moves the frame to the front.
Declaration
Swift
open func bringFrameToFront()
-
Moves the frame to the back.
Declaration
Swift
open func sendFrameToBack()
-
Whether or not the frame is in front of the overlays.
Declaration
Swift
open var isFrameInFront: Bool
-
Resets the rotation of the currently selected overlay.
Declaration
Swift
open func straightenSelectedOverlay()
-
Resets the rotation of the passed overlay.
Declaration
Swift
open func straightenOverlay(_ overlay: UIView)
Parameters
overlay
The overlay to reset.
-
Rotates the passed overlay be the specified radians.
Declaration
Swift
open func rotateOverlay(_ overlay: UIView, byRadians radians: CGFloat)
Parameters
overlay
The overlay to rotate.
radians
The amount of radians to rotate by.
-
Transforms the passed overlay from the specified transform to the other specified transform.
Declaration
Swift
open func transformOverlay(_ overlay: UIView, from startTransform: CGAffineTransform, to endTransform: CGAffineTransform)
Parameters
overlay
The overlay to transform.
startTransform
The start transform (this is only used for undo).
endTransform
The transform to apply to the overlay.
-
Resizes the passed overlay from the specified rect to the other specified rect.
Declaration
Swift
open func resizeOverlay(_ overlay: UIView, from startBounds: CGRect, to endBounds: CGRect)
Parameters
overlay
The overlay to resize.
startBounds
The start rect (this is only used for undo).
endBounds
The rect to resize the overlay to.
-
Moves the passed overlay from the specified point to the other specified point.
Declaration
Swift
open func moveOverlay(_ overlay: UIView, from startPoint: CGPoint, to endPoint: CGPoint)
Parameters
overlay
The overlay to move.
startPoint
The start point (this is only used for undo).
endPoint
The point to move the overlay to.
-
Moves and resizes the overlay.
Declaration
Swift
open func moveOverlay(_ overlay: UIView, from startPoint: CGPoint, to endPoint: CGPoint, resizingFrom startBounds: CGRect, toRect toBounds: CGRect)
Parameters
overlay
The overlay to move and resize.
startPoint
The start point (this is only used for undo).
endPoint
The point to move the overlay to.
startBounds
The start rect (this is only used for undo).
toBounds
The rect to resize the overlay to.
-
Flips the currently selected overlay horizontally.
Declaration
Swift
open func flipSelectedOverlay()
-
Flips the passed overlay horizontally. Currently only supports stickers.
Declaration
Swift
open func flipOverlay(_ overlay: UIView)
Parameters
overlay
The overlay to flip.
-
Changes the tint or background color (where appropriate) of an overlay.
Declaration
Swift
open func changeOverlay(_ overlay: UIView, from fromColor: UIColor, to toColor: UIColor, changeBackground: Bool)
Parameters
overlay
The overlay to change the color for.
fromColor
The start color (this is only used for undo).
toColor
The color to change to.
changeBackground
When
true
the background color is changed (where possible).
-
Changes the font of a text label.
Declaration
Swift
open func changeTextLabel(_ label: TextLabel, from fromFont: UIFont, to toFont: UIFont)
Parameters
label
The label to change the font of.
fromFont
The start font (this is only used for undo).
toFont
The font to change to.
-
Changes the text of a label.
Declaration
Swift
open func changeTextLabel(_ label: TextLabel, fromText: String?, toText: String?)
Parameters
label
The label to change the text of.
fromText
The text to change from (this is only used for undo).
toText
The text to change to.
-
Changes the text alignment of a label.
Declaration
Swift
open func changeTextLabel(_ label: TextLabel, fromAlignment: NSTextAlignment, toAlignment: NSTextAlignment)
Parameters
label
The label to change the alignment of.
fromAlignment
The alignment to change from (this is only used for undo).
toAlignment
The alignment to change to.
-
Removes the currently selected overlay.
Declaration
Swift
open func removeSelectedOverlay()
-
Removes the currently selected overlay.
Declaration
Swift
open func remove(overlay: UIView)