Skip to content

Altitude Widget

Shane Looker edited this page May 15, 2020 · 2 revisions

The altitude widget shows the current altitude of the aircraft. This uses the unit set in the global preferences and defaults to meters.

Images/DashboardWidgetImages/AltitudeWidget.gif

Usage

If creating the altitude 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 DUXBetaAltitudeWidget. From here you can create the constraints on the container view using the Altitude Widget's widgetSizeHint property.

Customizations

The altitude widget supports customization of its light and dark font colors, and its small and large fonts.

To get this effect we would use the following code:

Swift

altitudeWidget.lightFontColor = UIColor.green
altitudeWidget.darkFontColor = UIColor.blue
altitudeWidget.smallFont = UIFont(name: "Custom Font", size: 12.0)!
altitudeWidget.largeFont = UIFont(name: "Custom Font", size: 24.0)!

Objective C

altitudeWidget.lightFontColor = [UIColor greenColor];
altitudeWidget.darkFontColor = [UIColor blueColor];
altitudeWidget.smallFont = [UIFont fontWithName:@"Custom Font" size:12.0];
altitudeWidget.largeFont = [UIFont fontWithName:@"Custom Font" size:24.0];

Full list of properties

List of the customizable properties
  • lightFontColor - Font color for the altitude value, defaults to white.
  • darkFontColor - Font color for the altitude unit and name, defaults to gray.
  • smallFont - Font for the altitude value.
  • largeFont - Font for the altitude unit and name.
Clone this wiki locally