-
Notifications
You must be signed in to change notification settings - Fork 15
Photo Video Switch Widget
(Updated widget in develop branch)
This widget can be used to switch between Shoot Photo Mode and Record Video Mode. There are two states
Icon | Description |
---|---|
Shoot Photo Mode | |
Record Video Mode |
If creating the photo video switch widget through code it can be added using the convenience method:
- (void)installInViewController:(nullable UIViewController *)viewController
which adds the widget the method is called on, as a subview of the ViewController, that is passed in as an argument. Following this, add constraints to the widget using its widgetSizeHint
property to determine width, height and aspect ratio constraints.
If creating the widget through storyboard use the object library to drag a container view controller into the desired view controller like so:
Following this make sure to change the class of the child view controller to be DUXBetaPhotoVideoSwitchWidget
. From here you can create the constraints on the container view using the widgetSizeHint
property.
The UI elements can be customized to match the style of the user's application.
Icon | Description |
---|---|
Shoot Photo Mode | |
Record Video Mode |
widget.backgroundColor = .yellow
widget.photoModeTintColor = .red
widget.videoModeTintColor = .blue
widget.disconnectedTintColor = .darkGray
widget.backgroundColor = [UIColor yellowColor];
widget.photoModeTintColor = [UIColor redColor];
widget.videoModeTintColor = [UIColor blueColor];
widget.disconnectedTintColor = [UIColor darkGrayColor];
List of the customization APIs
-
public var cameraIndex: Int
- Index of the camera the widget model is communicating with. -
public var disconnectedTintColor: UIColor
- The tint color of the icon when product disconnected or camera disabled. -
public var photoModeImage: UIImage?
- The image of the icon when in photo mode. -
public var photoModeTintColor: UIColor
- The tint color of the icon when in video mode. -
public var videoModeImage: UIImage?
- The image of the icon when in video mode. -
public var videoModeTintColor: UIColor
- The tint color of the icon when in video mode. -
public var backgroundColor: UIColor
- The background color of the widget.
The widget provides hooks for the users to add functionality based on the state changes in the widget.
The DUXBetaPhotoVideoSwitchWidget
provides the following hooks:
-
PhotoVideoSwitchModelState
- Provides hooks in events received by the widget from the widget model.-
public static func productConnected(_ isConnected: Bool) -> PhotoVideoSwitchModelState
- Event when the product is connected or disconnected. -
public static func photoVideoStateUpdated(_ state: DUXBetaPhotoVideoSwitchState) -> PhotoVideoSwitchModelState
- Event when the photo video switch widget state changes.
-
-
PhotoVideoSwitchUIState
- Provides hooks in events received by the widget from user interface interactions.-
public static func widgetTapped() -> PhotoVideoSwitchUIState
- Event when the widget is tapped.
-
DJI UX SDK Version 5 Beta 4.1