UIHinge
An object encapsulating the state of a single hinge.
Declaration
@MainActor class UIHingeOverview
You observe hinge state by adding a UIHingeInteraction to a view and reading it from the update delivered to its handler.
override func viewDidLoad() {
super.viewDidLoad()
let interaction = UIHingeInteraction { [weak self] _, update in
guard let self else { return }
// A nil `hinge` indicates the interaction has left a
// hierarchy that provides hinge updates.
guard let hinge = update.hinge else {
handleHingeUnavailable()
return
}
updateAngleDisplay(with: hinge.angle)
updateStatusDisplay(with: hinge.status)
}
view.addInteraction(interaction)
}In the example above, the current angle and status of the hinge are displayed as the user interacts with the hinge.