Instance Property インスタンスプロパティ

verticalSizeClass

The vertical size class of this environment. この環境の垂直サイズ等級。

Declaration 宣言

var verticalSizeClass: UserInterfaceSizeClass? { get set }

Discussion 議論

You receive a UserInterfaceSizeClass value when you read this environment value. The value tells you about the amount of vertical space available to the view that reads it. You can read this size class like any other of the EnvironmentValues, by creating a property with the Environment property wrapper:


@Environment(\.verticalSizeClass) private var verticalSizeClass

SwiftUI sets this size class based on several factors, including:

  • The current device type.

  • The orientation of the device.

You can adjust the appearance of custom views by reading this size class and conditioning your views. If you do, be prepared to handle size class changes while your app runs, because factors like device orientation can change at runtime.

See Also 参照

Display Characteristics