Structure

EnvironmentValues

A collection of environment values propagated through a view hierarchy.

Declaration

struct EnvironmentValues

Topics

Creating an Environment Values Instance

init()

Creates an environment values instance.

Accessing Color Schemes

var colorScheme: ColorScheme

The color scheme of this environment.

enum ColorScheme

The possible types of color schemes, like Dark Mode.

var colorSchemeContrast: ColorSchemeContrast

The contrast associated with the color scheme of this environment.

enum ColorSchemeContrast

Options indicating whether the system uses standard or increased contrast between the app's foreground and background colors.

Accessing Control Attributes

Accessing List Styles

var defaultMinListHeaderHeight: CGFloat?

The default minimum height of a header in a list.

var defaultMinListRowHeight: CGFloat

The default minimum height of a row in a list.

Accessing Paragraph Styles

var allowsTightening: Bool

A Boolean value that indicates whether inter-character spacing should tighten to fit the text into the available space.

var layoutDirection: LayoutDirection

The layout direction associated with the current environment.

var lineLimit: Int?

The maximum number of lines that text can occupy in a view.

var lineSpacing: CGFloat

The distance in points between the bottom of one line fragment and the top of the next.

var minimumScaleFactor: CGFloat

The minimum permissible proportion to shrink the font size to fit the text into the available space.

var multilineTextAlignment: TextAlignment

A value that indicates how text instance aligns its lines when the content wraps or contains newlines.

var sizeCategory: ContentSizeCategory

The preferred size of the content.

var truncationMode: Text.TruncationMode

A value that indicates how the layout truncates the last line of text to fit into the available space.

Accessing Text Field Styles

var disableAutocorrection: Bool?

A Boolean value that determines whether the view hierarchy has auto-correction enabled.

Accessing Wheel Picker Styles

var defaultWheelPickerItemHeight: CGFloat

The default height of an item in a wheel-style picker, such as a date picker.

Accessing View Settings

var calendar: Calendar

The current calendar that views should use when handling dates.

var editMode: Binding<EditMode>?

The mode indicating whether the user can edit the contents of a view associated with this environment.

enum EditMode

The mode of a view indicating whether the user can edit its content.

var isEnabled: Bool

A Boolean value that indicates whether the view associated with this environment allows user interaction.

var locale: Locale

The current locale that views should use.

var presentationMode: Binding<PresentationMode>

A binding to the current presentation mode of the view associated with this environment.

var timeZone: TimeZone

The current time zone that views should use when handling dates.

Accessing Size Classes

var horizontalSizeClass: UserInterfaceSizeClass?

The horizontal size class of this environment.

var verticalSizeClass: UserInterfaceSizeClass?

The vertical size class of this environment.

enum UserInterfaceSizeClass

A set of values that indicate the visual size available to the view.

Access the Undo Manager

var undoManager: UndoManager?

The undo manager used to register a view’s undo operations.

Access Other Environment Values

var displayScale: CGFloat

The display scale of this environment.

var font: Font?

The default font of this environment.

var imageScale: Image.Scale

The image scale for this environment.

var pixelLength: CGFloat

The size of a pixel on the screen.

Accessing Values Using Dynamic Member Lookup

Retrieving String Representations

var description: String

A string that represents the contents of the environment values instance.

Relationships

See Also

Environment Data

struct Environment

A property wrapper type that reads a value from the view’s environment.

struct EnvironmentObject

A property wrapper type for an observable object supplied by a parent or ancestor view.