DeviceHinge
A type encapsulating the state of a single hinge.
Declaration
type DeviceHinge = { readonly angle: Angle; readonly hashValue: number; readonly status: DeviceHingeStatus; };struct DeviceHingeProperties
angle*AnglehashValue*numberstatus*DeviceHingeStatus
Overview
A hinge provides its angle along with a status determined by the
system based on the current angle and device orientation. You use this type
with the View.onHingeChange(_:) modifier.
@State private var hinge: DeviceHinge? = nil
var body: some View {
VStack {
if let hinge {
AngleDisplayView(angle: hinge.angle)
StatusDisplayView(status: hinge.status)
} else {
ContentUnavailableView(
"Hinge Unavailable",
systemImage: "rectangle.split.2x1")
}
}
.onHingeChange { _, newContext in
hinge = newContext.hinge
}
}In the example above, the current angle and status of the hinge will be displayed in the app as you interact with the hinge.
From Apple’s SwiftUI documentation. Code samples there are Swift.
See also
More in Other values.
- AxisThe horizontal or vertical dimension in a 2D coordinate system.
- AxisSetAn efficient set of axes.
- ButtonRoleA value that describes the purpose of a button.
- CapsuleA capsule shape aligned inside the frame of the view containing it.
- CircleA circle centered on the frame of the view containing it.
- ConcentricRectangleA shape whose corners you configure, individually or uniformly, to be squared, rounded, or concentric relative to a container shape's corners.
- ContentMarginGuideA guide for resolving the content margins for a view.
- ContentMarginPlacementThe placement of margins.
- ContentModeConstants that define how a view's content fills the available space.
- DatePickerComponents
- DatePickerComponents2The date and time components that a date picker shows.
- DeviceHingeContextA type describing the context of hinges on the device.