Enumeration 列挙

UserInterfaceSizeClass

A set of values that indicate the visual size available to the view. 一揃いの値、それはビューに利用可能な視覚的大きさを指し示します。

Declaration 宣言

enum UserInterfaceSizeClass

Overview 概要

You receive a size class value when you read either the horizontalSizeClass or verticalSizeClass environment value. The value tells you about the amount of space available to your views in a given direction. You can read the size class like any other of the EnvironmentValues, by creating a property with the Environment property wrapper:


@Environment(\.horizontalSizeClass) private var horizontalSizeClass
@Environment(\.verticalSizeClass) private var verticalSizeClass

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

  • The current device type.

  • The orientation of the device.

  • The appearance of Slide Over and Split View on iPad.

Several built-in views change their behavior based on the size class. For example, a NavigationView presents a multicolumn view when the horizontal size class is UserInterfaceSizeClass.regular, but a single column otherwise. You can also adjust the appearance of custom views by reading the 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.

Topics 話題

Getting Size Classes

Creating a Size Class

Comparing Size Classes サイズクラスを比較する

Default Implementations 省略時実装

Relationships 関係

Conforms To 次に準拠

See Also 参照

Configuration