CameraController
@objcMembers
public class CameraController : 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
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.
-
Set this delegate in order to handle events that occur in this controller.
Default value:
nil
Declaration
Swift
public weak var delegate: CameraControllerDelegate?
-
Set this to false if you do not want the
EditController
pushed onto the navigation stack after the user takes a photo or presses the Done button after taking a video.You can push your own controller or dismiss this controller in the
cameraController(_:didFinishWithSession:)
delegate method.Default value:
true
Declaration
Swift
public var showsEditControllerWhenDone: Bool
-
Set this to true if you want the flash enabled.
Default value:
false
Declaration
Swift
public var flashActive: Bool { get set }
-
Set this to true if you want the front facing camera enabled or to false if you want the back facing camera enabled.
Default value:
false
Declaration
Swift
public var frontFacingCameraActive: Bool { get set }
-
Set this to true if you want the brightness slider to be visible.
Default value:
false
Declaration
Swift
public var brightnessAdjustmentActive: Bool { get set }
-
When true, if the device is held horizontally with the screen face up, the mode pictured below will appear.
Default value:
true
Declaration
Swift
public var faceUpModeAvailable: Bool
-
When true, the user may double tap anywhere inside the camera view to switch between the front and back facing camera.
Default value:
true
Declaration
Swift
public var doubleTapForFrontFacingCamera: Bool { get set }
-
These are the buttons at the top of the camera. The buttons will also be displayed in the order provided here.
Default value:
[.cross, .reverse, .brightness, .square, .flash]
Declaration
Swift
public var controlButtons: [CameraControlButton] { get set }
-
Optionally provide a custom view for the photo camera button. Your view must determine its own size with intrinsic content size or constraints.
Default value:
nil
Declaration
Swift
public var photoCameraButtonView: UIView? { get set }
-
Optionally provide a custom view for the video camera button. Your view must determine its own size with intrinsic content size or constraints.
Default value:
nil
Declaration
Swift
public var videoCameraButtonView: UIView? { get set }
-
Set this if you want to force the camera controller to produce content in a specific aspect ratio.
For example square:
CGSize(width: 1, height: 1)
Or the same ratio as vertical 1080p video:
CGSize(width: 1080, height: 1920)
orCGSize(width: 9, height: 16)
When set with a value, the
.square
button in thecontrolButtons
will be hidden.Default value:
nil
Declaration
Swift
public var aspectRatio: CGSize? { get set }
-
The session preset for video capture.
Default value:
.high
Declaration
Swift
public var videoPreset: AVCaptureSession.Preset { get set }
-
A closure that returns newly allocated photo settings for photo capture.
If you wish to enable or disable flash, set the
flashActive
variable.Default value:
{ let photoSettings = AVCapturePhotoSettings() photoSettings.isAutoStillImageStabilizationEnabled = true photoSettings.isHighResolutionPhotoEnabled = true return photoSettings }
Declaration
Swift
public var photoSettings: () -> (AVCapturePhotoSettings) { get set }
-
Use
aspectRatio
instead to enable square camera.Default value:
false
Declaration
Swift
@available(*, deprecated, message: "Only set aspectRatio now. This variable is no longer needed.") public var squareCameraActive: Bool { get set }