Contents

WKInterfaceVolumeControl

An interface element that provides control of the audio volume from the watch or a paired iPhone.

Declaration

class WKInterfaceVolumeControl

Overview

Configure your app’s audio source and the appearance of the volume control in your storyboard file. Use the WKInterfaceVolumeControl instance to change the volume’s tint color at runtime.

Do not subclass or create instances of this class yourself. Instead, define outlets in your interface controller class and connect them to the corresponding objects in your storyboard file. For example, to refer to a volume control in your interface, define a property with the following syntax in your interface controller class:

During the initialization of your interface controller, WatchKit creates a new instance of this class and assigns it to your outlet. At that point, you can use the object in your outlet to make changes to the onscreen control.

After selecting the volume control, the user can increase or decrease the audio’s volume using the crown. The system automatically handles changing the audio source’s volume. You cannot access or change the volume programmatically in your app.

Interface Builder Configuration Options

Xcode lets you configure your volume control in your storyboard file. The following table lists the attributes you can configure and their meaning.

Attribute

Description

Controls Local Volume

The volume control’s audio source. If checked, the control affects the volume of long-form audio playing on the watch. If unchecked, it affects the volume of audio playing on the paired iPhone. [Image] You must set this value at design time. You cannot change its value programmatically.

Tint Color

The tint color for the volume control. By default, the system uses the application’s tint color. [Image] The system only applies the tint color to the control’s default state (when the crown is not being used to adjust the volume). [Image] You can change this value programmatically using the Settintcolor(_:) method.

Topics

Setting the Tint Color

Managing Input from the Digital Crown

SwiftUI

See Also

Audio