Created
July 27, 2021 18:31
-
-
Save duraidabdul/99e8498d24f93dae9cedb6bd454c1f09 to your computer and use it in GitHub Desktop.
Xcode 13.0 beta 4 SwiftUI Interface (Part 2)
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// the `Element` type must be `Self`, the default. | |
public typealias Element = DatePickerComponents | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt | |
} | |
/// A type that specifies the appearance and interaction of all date pickers | |
/// within a view hierarchy. | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public protocol DatePickerStyle { | |
} | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DatePickerStyle where Self == DefaultDatePickerStyle { | |
/// The default style for date pickers. | |
public static var automatic: DefaultDatePickerStyle { get } | |
} | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DatePickerStyle where Self == GraphicalDatePickerStyle { | |
/// A date picker style that displays an interactive calendar or clock. | |
/// | |
/// This style is useful when you want to allow browsing through days in a | |
/// calendar, or when the look of a clock face is appropriate. | |
public static var graphical: GraphicalDatePickerStyle { get } | |
} | |
@available(iOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DatePickerStyle where Self == WheelDatePickerStyle { | |
/// A date picker style that displays each component as columns in a | |
/// scrollable wheel. | |
public static var wheel: WheelDatePickerStyle { get } | |
} | |
@available(iOS 14.0, macCatalyst 13.4, macOS 10.15.4, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DatePickerStyle where Self == CompactDatePickerStyle { | |
/// A date picker style that displays the components in a compact, textual | |
/// format. | |
/// | |
/// Use this style when space is constrained and users expect to make | |
/// specific date and time selections. Some variants may include rich | |
/// editing controls in a pop up. | |
public static var compact: CompactDatePickerStyle { get } | |
} | |
/// The default button style, based on the button's context. | |
/// | |
/// Do not use this type directly. Instead, use | |
/// ``PrimitiveButtonStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct DefaultButtonStyle : PrimitiveButtonStyle { | |
/// Creates a default button style. | |
public init() | |
/// Creates a view that represents the body of a button. | |
/// | |
/// The system calls this method for each ``Button`` instance in a view | |
/// hierarchy where this style is the current button style. | |
/// | |
/// - Parameter configuration : The properties of the button. | |
public func makeBody(configuration: DefaultButtonStyle.Configuration) -> some View | |
/// A view that represents the body of a button. | |
public typealias Body = some View | |
} | |
/// The default control group style. | |
/// | |
/// Do not use this type directly. Instead, use ``ControlGroupStyle/automatic``. | |
@available(iOS, deprecated, renamed: "AutomaticControlGroupStyle") | |
@available(macOS, introduced: 12.0, deprecated: 12.0, renamed: "AutomaticControlGroupStyle") | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DefaultControlGroupStyle : ControlGroupStyle { | |
/// Creates a default control group style. | |
public init() | |
/// Creates a view representing the body of a control group. | |
/// | |
/// - Parameter configuration: The properties of the control group instance | |
/// being created. | |
/// | |
/// This method will be called for each instance of ``ControlGroup`` created | |
/// within a view hierarchy where this style is the current | |
/// `ControlGroupStyle`. | |
public func makeBody(configuration: DefaultControlGroupStyle.Configuration) -> some View | |
/// A view representing the body of a control group. | |
public typealias Body = some View | |
} | |
/// The default style for date pickers. | |
/// | |
/// Do not use this type directly. Instead, use ``DatePickerStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DefaultDatePickerStyle : DatePickerStyle { | |
/// Creates an instance of the default date picker style. | |
public init() | |
} | |
/// The default style for group box views. | |
/// | |
/// Do not use this type directly. Instead, use ``GroupBoxStyle/automatic``. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DefaultGroupBoxStyle : GroupBoxStyle { | |
public init() | |
/// Creates a view representing the body of a group box. | |
/// | |
/// SwiftUI calls this method for each instance of ``SwiftUI/GroupBox`` | |
/// created within a view hierarchy where this style is the current | |
/// group box style. | |
/// | |
/// - Parameter configuration: The properties of the group box instance being | |
/// created. | |
public func makeBody(configuration: DefaultGroupBoxStyle.Configuration) -> some View | |
/// A view that represents the body of a group box. | |
public typealias Body = some View | |
} | |
/// The default label style in the current context. | |
/// | |
/// Do not use this type directly. Instead, use ``LabelStyle/automatic``. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct DefaultLabelStyle : LabelStyle { | |
/// Creates a default label style. | |
public init() | |
/// Creates a view that represents the body of a label. | |
/// | |
/// The system calls this method for each ``Label`` instance in a view | |
/// hierarchy where this style is the current label style. | |
/// | |
/// - Parameter configuration: The properties of the label. | |
public func makeBody(configuration: DefaultLabelStyle.Configuration) -> some View | |
/// A view that represents the body of a label. | |
public typealias Body = some View | |
} | |
/// The list style that describes a platform's default behavior and appearance | |
/// for a list. | |
/// | |
/// Do not use this type directly. Instead, use ``ListStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct DefaultListStyle : ListStyle { | |
/// Creates a default list style. | |
public init() | |
} | |
/// The default menu style, based on the menu's context. | |
/// | |
/// Do not use this type directly. Instead, use ``MenuStyle/automatic``. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DefaultMenuStyle : MenuStyle { | |
/// Creates a default menu style. | |
public init() | |
/// Creates a view that represents the body of a menu. | |
/// | |
/// - Parameter configuration: The properties of the menu. | |
/// | |
/// The system calls this method for each ``Menu`` instance in a view | |
/// hierarchy where this style is the current menu style. | |
public func makeBody(configuration: DefaultMenuStyle.Configuration) -> some View | |
/// A view that represents the body of a menu. | |
public typealias Body = some View | |
} | |
/// The default navigation view style. | |
/// | |
/// Do not use this type directly. Instead, use | |
/// ``NavigationViewStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
public struct DefaultNavigationViewStyle : NavigationViewStyle { | |
public init() | |
} | |
/// The default picker style, based on the picker's context. | |
/// | |
/// Do not use this type directly. Instead, use ``PickerStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct DefaultPickerStyle : PickerStyle { | |
/// Creates a default picker style. | |
public init() | |
} | |
/// The default progress view style in the current context of the view being | |
/// styled. | |
/// | |
/// Do not use this type directly. Instead, use ``ProgressViewStyle/automatic``. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct DefaultProgressViewStyle : ProgressViewStyle { | |
/// Creates a default progress view style. | |
public init() | |
/// Creates a view representing the body of a progress view. | |
/// | |
/// - Parameter configuration: The properties of the progress view being | |
/// created. | |
/// | |
/// The view hierarchy calls this method for each progress view where this | |
/// style is the current progress view style. | |
/// | |
/// - Parameter configuration: The properties of the progress view, such as | |
/// its preferred progress type. | |
public func makeBody(configuration: DefaultProgressViewStyle.Configuration) -> some View | |
/// A view representing the body of a progress view. | |
public typealias Body = some View | |
} | |
/// The default `TabView` style. | |
/// | |
/// Do not use this type directly. Instead, use ``TabViewStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
public struct DefaultTabViewStyle : TabViewStyle { | |
public init() | |
} | |
/// The default text field style, based on the text field's context. | |
/// | |
/// Do not use this type directly. Instead, use ``TextFieldStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct DefaultTextFieldStyle : TextFieldStyle { | |
public init() | |
} | |
/// The default toggle style. | |
/// | |
/// Do not use this type directly. Instead, use ``ToggleStyle/automatic``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct DefaultToggleStyle : ToggleStyle { | |
/// Creates a default toggle style. | |
public init() | |
/// Creates a view that represents the body of a toggle. | |
/// | |
/// The system calls this method for each ``Toggle`` instance in a view | |
/// hierarchy where this style is the current toggle style. | |
/// | |
/// - Parameter configuration: The properties of the toggle. | |
public func makeBody(configuration: DefaultToggleStyle.Configuration) -> some View | |
/// A view that represents the appearance and interaction of a toggle. | |
public typealias Body = some View | |
} | |
/// Disables text selection by the user. | |
/// | |
/// Do not use this type directly. Instead, use ``TextSelectability/disabled``. | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DisabledTextSelectability : TextSelectability { | |
/// Whether text allows selection or not. | |
/// | |
/// This should produce a constant value that is not affected by global | |
/// state. | |
public static let allowsSelection: Bool | |
} | |
/// A view that shows or hides another content view, based on the state of a | |
/// disclosure control. | |
/// | |
/// A disclosure group view consists of a label to identify the contents, and a | |
/// control to show and hide the contents. Showing the contents puts the | |
/// disclosure group into the "expanded" state, and hiding them makes the | |
/// disclosure group "collapsed". | |
/// | |
/// In the following example, a disclosure group contains two toggles and | |
/// an embedded disclosure group. The top level disclosure group exposes its | |
/// expanded state with the bound property, `topLevelExpanded`. By expanding | |
/// the disclosure group, the user can use the toggles to update the state of | |
/// the `toggleStates` structure. | |
/// | |
/// struct ToggleStates { | |
/// var oneIsOn: Bool = false | |
/// var twoIsOn: Bool = true | |
/// } | |
/// @State private var toggleStates = ToggleStates() | |
/// @State private var topExpanded: Bool = true | |
/// | |
/// var body: some View { | |
/// DisclosureGroup("Items", isExpanded: $topExpanded) { | |
/// Toggle("Toggle 1", isOn: $toggleStates.oneIsOn) | |
/// Toggle("Toggle 2", isOn: $toggleStates.twoIsOn) | |
/// DisclosureGroup("Sub-items") { | |
/// Text("Sub-item 1") | |
/// } | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DisclosureGroup<Label, Content> : View where Label : View, Content : View { | |
/// Creates a disclosure group with the given label and content views. | |
/// | |
/// - Parameters: | |
/// - content: The content shown when the disclosure group expands. | |
/// - label: A view that describes the content of the disclosure group. | |
public init(@ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label) | |
/// Creates a disclosure group with the given label and content views, and | |
/// a binding to the expansion state (expanded or collapsed). | |
/// | |
/// - Parameters: | |
/// - isExpanded: A binding to a Boolean value that determines the group's | |
/// expansion state (expanded or collapsed). | |
/// - content: The content shown when the disclosure group expands. | |
/// - label: A view that describes the content of the disclosure group. | |
public init(isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content, @ViewBuilder label: () -> Label) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DisclosureGroup where Label == Text { | |
/// Creates a disclosure group, using a provided localized string key to | |
/// create a text view for the label. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized label of `self` that describes | |
/// the content of the disclosure group. | |
/// - content: The content shown when the disclosure group expands. | |
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: @escaping () -> Content) | |
/// Creates a disclosure group, using a provided localized string key to | |
/// create a text view for the label, and a binding to the expansion state | |
/// (expanded or collapsed). | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized label of `self` that describes | |
/// the content of the disclosure group. | |
/// - isExpanded: A binding to a Boolean value that determines the group's | |
/// expansion state (expanded or collapsed). | |
/// - content: The content shown when the disclosure group expands. | |
public init(_ titleKey: LocalizedStringKey, isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content) | |
/// Creates a disclosure group, using a provided string to create a | |
/// text view for the label. | |
/// | |
/// - Parameters: | |
/// - label: A description of the content of the disclosure group. | |
/// - content: The content shown when the disclosure group expands. | |
public init<S>(_ label: S, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol | |
/// Creates a disclosure group, using a provided string to create a | |
/// text view for the label, and a binding to the expansion state (expanded | |
/// or collapsed). | |
/// | |
/// - Parameters: | |
/// - label: A description of the content of the disclosure group. | |
/// - isExpanded: A binding to a Boolean value that determines the group's | |
/// expansion state (expanded or collapsed). | |
/// - content: The content shown when the disclosure group expands. | |
public init<S>(_ label: S, isExpanded: Binding<Bool>, @ViewBuilder content: @escaping () -> Content) where S : StringProtocol | |
} | |
/// Provides functionality for dismissing a presentation. | |
/// | |
/// The `DismissAction` instance in the app's ``Environment`` offers a handler | |
/// that you can use to dismiss a presentation. The action has no effect if the | |
/// view is not currently being presented. You can use | |
/// ``EnvironmentValues/isPresented`` to query whether the view is currently | |
/// being presented. | |
/// | |
/// Use the ``EnvironmentValues/dismiss`` environment value to get the handler. | |
/// Then call the action's handler to perform the dismissal. For example, | |
/// you can use the action to add a done button to a sheet's toolbar: | |
/// | |
/// struct SheetView: View { | |
/// @Environment(\.dismiss) var dismiss | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// SheetContents() | |
/// .toolbar { | |
/// Button("Done") { | |
/// dismiss() | |
/// } | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct DismissAction { | |
/// Dismisses the view if it is currently presented. | |
/// | |
/// Use this method to attempt to dismiss a presentation. This function | |
/// is used when you call the function ``dismiss()``. | |
public func callAsFunction() | |
} | |
/// Provides functionality for dismissing a search interaction. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct DismissSearchAction { | |
/// Requests the current view hierarchy to end searching. | |
public func callAsFunction() | |
} | |
/// A visual element that can be used to separate other content. | |
/// | |
/// When contained in a stack, the divider extends across the minor axis of the | |
/// stack, or horizontally when not in a stack. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct Divider : View { | |
public init() | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A scene that enables support for opening, creating, and saving documents. | |
/// | |
/// Use a `DocumentGroup` scene to tell SwiftUI what kinds of documents your | |
/// app can open when you declare your app using the ``App`` protocol. | |
/// | |
/// Initialize a document group scene by passing in the document model and a | |
/// view capable of displaying the document type. The document types you supply | |
/// to `DocumentGroup` must conform to ``FileDocument`` or | |
/// ``ReferenceFileDocument``. SwiftUI uses the model to add document support | |
/// to your app. In macOS this includes document-based menu support, including | |
/// the ability to open multiple documents. In iOS this includes a document | |
/// browser that can navigate to the documents stored on the file system | |
/// and multiwindow support: | |
/// | |
/// @main | |
/// struct MyApp: App { | |
/// var body: some Scene { | |
/// DocumentGroup(newDocument: TextFile()) { file in | |
/// ContentView(document: file.$document) | |
/// } | |
/// } | |
/// } | |
/// | |
/// If your app only needs to display but not modify a specific | |
/// document type, you can use the file viewer document group scene. You | |
/// supply the file type of the document, and a view that displays the | |
/// document type that you provide: | |
/// | |
/// @main | |
/// struct MyApp: App { | |
/// var body: some Scene { | |
/// DocumentGroup(viewing: MyImageFormatDocument.self) { | |
/// MyImageFormatViewer(image: $0.document) | |
/// } | |
/// } | |
/// } | |
/// | |
/// Your app can support multiple document types by adding additional | |
/// document group scenes: | |
/// | |
/// @main | |
/// struct MyApp: App { | |
/// var body: some Scene { | |
/// DocumentGroup(newDocument: TextFile()) { group in | |
/// ContentView(document: group.$document) | |
/// } | |
/// DocumentGroup(viewing: MyImageFormatDocument.self) { group in | |
/// MyImageFormatViewer(image: group.document) | |
/// } | |
/// } | |
/// } | |
/// | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DocumentGroup<Document, Content> : Scene where Content : View { | |
/// The content and behavior of the scene. | |
/// | |
/// For any scene that you create, provide a computed `body` property that | |
/// defines the scene as a composition of other scenes. You can assemble a | |
/// scene from primitive scenes that SwiftUI provides, as well as other | |
/// scenes that you've defined. | |
/// | |
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype`` | |
/// associated type based on the contents of the `body` property. | |
public var body: some Scene { get } | |
/// The type of scene that represents the body of this scene. | |
/// | |
/// When you create a custom scene, Swift infers this type from your | |
/// implementation of the required ``SwiftUI/Scene/body-swift.property`` | |
/// property. | |
public typealias Body = some Scene | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DocumentGroup where Document : FileDocument { | |
/// Creates a document group for creating and editing file documents. | |
/// | |
/// Use a ``DocumentGroup`` scene to tell SwiftUI what kinds of documents | |
/// your app can open when you declare your app using the ``App`` protocol. | |
/// You initialize a document group scene by passing in the document model | |
/// and a view capable of displaying the document's contents. The document | |
/// types you supply to ``DocumentGroup`` must conform to ``FileDocument`` | |
/// or ``ReferenceFileDocument``. SwiftUI uses the model to add document | |
/// support to your app. In macOS this includes document-based menu support | |
/// including the ability to open multiple documents. In iOS this includes | |
/// a document browser that can navigate to the documents stored on the | |
/// file system and multiwindow support: | |
/// | |
/// @main | |
/// struct MyApp: App { | |
/// var body: some Scene { | |
/// DocumentGroup(newDocument: TextFile()) { file in | |
/// ContentView(document: file.$document) | |
/// } | |
/// } | |
/// } | |
/// | |
/// The document types you supply to ``DocumentGroup`` must conform to | |
/// ``FileDocument`` or ``ReferenceFileDocument``. Your app can support | |
/// multiple document types by adding additional ``DocumentGroup`` scenes. | |
/// | |
/// - Parameters: | |
/// - newDocument: The initial document to use when a user creates | |
/// a new document. | |
/// - editor: The editing UI for the provided document. | |
public init(newDocument: @autoclosure @escaping () -> Document, @ViewBuilder editor: @escaping (FileDocumentConfiguration<Document>) -> Content) | |
/// Creates a document group capable of viewing file documents. | |
/// | |
/// Use this method to create a document group that can view files of a | |
/// specific type. The example below creates a new document viewer for | |
/// `MyImageFormatDocument` and displays them with `MyImageFormatViewer`: | |
/// | |
/// @main | |
/// struct MyApp: App { | |
/// var body: some Scene { | |
/// DocumentGroup(viewing: MyImageFormatDocument.self) { file in | |
/// MyImageFormatViewer(image: file.document) | |
/// } | |
/// } | |
/// } | |
/// | |
/// - Parameters: | |
/// - documentType: The type of document your app can view. | |
/// - viewer: The viewing UI for the provided document. | |
/// | |
/// You tell the system about the app's role with respect to the document | |
/// type by setting the | |
/// <doc://com.apple.documentation/documentation/BundleResources/Information_Property_List/CFBundleDocumentTypes/CFBundleTypeRole> | |
/// `Info.plist` key with a value of `Viewer`. | |
/// | |
public init(viewing documentType: Document.Type, @ViewBuilder viewer: @escaping (FileDocumentConfiguration<Document>) -> Content) | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DocumentGroup where Document : ReferenceFileDocument { | |
/// Creates a document group that is able to create and edit reference file | |
/// documents. | |
/// | |
/// - Parameters: | |
/// - newDocument: The initial document used when the user creates | |
/// a new document. The argument should create a new instance, such that | |
/// a new document is created on each invocation of the closure. | |
/// - editor: The editing UI for the provided document. | |
/// | |
/// The current document for a given editor instance is also provided as an | |
/// environment object for its subhierarchy. | |
/// | |
/// Undo support is not automatically provided for this construction of | |
/// a `DocumentGroup`, and any updates to the document by the editor view | |
/// hierarchy are expected to register undo operations when appropriate. | |
public init(newDocument: @escaping () -> Document, @ViewBuilder editor: @escaping (ReferenceFileDocumentConfiguration<Document>) -> Content) | |
/// Creates a document group that is able to view reference file documents. | |
/// | |
/// - Parameters: | |
/// - documentType: The type of document being viewed. | |
/// - viewer: The viewing UI for the provided document. | |
/// | |
/// The current document for a given editor instance is also provided as an | |
/// environment object for its subhierarchy. | |
/// | |
/// - See Also: `CFBundleTypeRole` with a value of "Viewer" | |
public init(viewing documentType: Document.Type, @ViewBuilder viewer: @escaping (ReferenceFileDocumentConfiguration<Document>) -> Content) | |
} | |
/// A navigation view style represented by a primary view stack that | |
/// navigates to a detail view. | |
@available(iOS, introduced: 13.0, deprecated: 100000, message: "Use NavigationViewStyle.columns") | |
@available(macOS, introduced: 10.15, deprecated: 100000, message: "Use NavigationViewStyle.columns") | |
@available(tvOS, introduced: 13.0, deprecated: 100000, message: "Use NavigationViewStyle.stack") | |
@available(watchOS, unavailable) | |
public struct DoubleColumnNavigationViewStyle : NavigationViewStyle { | |
public init() | |
} | |
/// A dragging motion that invokes an action as the drag-event sequence changes. | |
/// | |
/// To recognize a drag gesture on a view, create and configure the gesture, and | |
/// then add it to the view using the ``View/gesture(_:including:)`` modifier. | |
/// | |
/// Add a drag gesture to a ``Circle`` and change its color while the user | |
/// performs the drag gesture: | |
/// | |
/// struct DragGestureView: View { | |
/// @State var isDragging = false | |
/// | |
/// var drag: some Gesture { | |
/// DragGesture() | |
/// .onChanged { _ in self.isDragging = true } | |
/// .onEnded { _ in self.isDragging = false } | |
/// } | |
/// | |
/// var body: some View { | |
/// Circle() | |
/// .fill(self.isDragging ? Color.red : Color.blue) | |
/// .frame(width: 100, height: 100, alignment: .center) | |
/// .gesture(drag) | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
public struct DragGesture : Gesture { | |
/// The attributes of a drag gesture. | |
public struct Value : Equatable { | |
/// The time associated with the drag gesture's current event. | |
public var time: Date | |
/// The location of the drag gesture's current event. | |
public var location: CGPoint | |
/// The location of the drag gesture's first event. | |
public var startLocation: CGPoint | |
/// The total translation from the start of the drag gesture to the | |
/// current event of the drag gesture. | |
/// | |
/// This is equivalent to `location.{x,y} - startLocation.{x,y}`. | |
public var translation: CGSize { get } | |
/// A prediction, based on the current drag velocity, of where the final | |
/// location will be if dragging stopped now. | |
public var predictedEndLocation: CGPoint { get } | |
/// A prediction, based on the current drag velocity, of what the final | |
/// translation will be if dragging stopped now. | |
public var predictedEndTranslation: CGSize { get } | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: DragGesture.Value, b: DragGesture.Value) -> Bool | |
} | |
/// The minimum dragging distance before the gesture succeeds. | |
public var minimumDistance: CGFloat | |
/// The coordinate space in which to receive location values. | |
public var coordinateSpace: CoordinateSpace | |
/// Creates a dragging gesture with the minimum dragging distance before the | |
/// gesture succeeds and the coordinate space of the gesture's location. | |
/// | |
/// - Parameters: | |
/// - minimumDistance: The minimum dragging distance for the gesture to | |
/// succeed. | |
/// - coordinateSpace: The coordinate space of the dragging gesture's | |
/// location. | |
public init(minimumDistance: CGFloat = 10, coordinateSpace: CoordinateSpace = .local) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
} | |
/// An interface that you implement to interact with a drop operation in a view | |
/// modified to accept drops. | |
/// | |
/// The ``DropDelegate`` protocol provides a comprehensive and flexible way to | |
/// interact with a drop operation. Specify a drop delegate when you modify a | |
/// view to accept drops with the ``View/onDrop(of:delegate:)-6lin8`` method. | |
/// | |
/// Alternatively, for simple drop cases that don't require the full | |
/// functionality of a drop delegate, you can modify a view to accept drops | |
/// using the ``View/onDrop(of:isTargeted:perform:)-f15m`` or the | |
/// ``View/onDrop(of:isTargeted:perform:)-982eu`` method. These methods handle the | |
/// drop using a closure you provide as part of the modifier. | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public protocol DropDelegate { | |
/// Tells the delegate that a drop containing items conforming to one of the | |
/// expected types entered a view that accepts drops. | |
/// | |
/// Specify the expected types when you apply the drop modifier to the view. | |
/// The default implementation returns `true`. | |
func validateDrop(info: DropInfo) -> Bool | |
/// Tells the delegate it can request the item provider data from the given | |
/// information. | |
/// | |
/// Incorporate the received data into your app's data model as appropriate. | |
/// - Returns: A Boolean that is `true` if the drop was successful, `false` | |
/// otherwise. | |
func performDrop(info: DropInfo) -> Bool | |
/// Tells the delegate a validated drop has entered the modified view. | |
/// | |
/// The default implementation does nothing. | |
func dropEntered(info: DropInfo) | |
/// Tells the delegate that a validated drop moved inside the modified view. | |
/// | |
/// Use this method to return a drop proposal containing the operation the | |
/// delegate intends to perform at the drop ``DropInfo/location``. The | |
/// default implementation of this method returns `nil`, which tells the | |
/// drop to use the last valid returned value or else | |
/// ``DropOperation/copy``. | |
func dropUpdated(info: DropInfo) -> DropProposal? | |
/// Tells the delegate a validated drop operation has exited the modified | |
/// view. | |
/// | |
/// The default implementation does nothing. | |
func dropExited(info: DropInfo) | |
} | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DropDelegate { | |
/// Tells the delegate that a drop containing items conforming to one of the | |
/// expected types entered a view that accepts drops. | |
/// | |
/// Specify the expected types when you apply the drop modifier to the view. | |
/// The default implementation returns `true`. | |
public func validateDrop(info: DropInfo) -> Bool | |
/// Tells the delegate a validated drop has entered the modified view. | |
/// | |
/// The default implementation does nothing. | |
public func dropEntered(info: DropInfo) | |
/// Tells the delegate that a validated drop moved inside the modified view. | |
/// | |
/// Use this method to return a drop proposal containing the operation the | |
/// delegate intends to perform at the drop ``DropInfo/location``. The | |
/// default implementation of this method returns `nil`, which tells the | |
/// drop to use the last valid returned value or else | |
/// ``DropOperation/copy``. | |
public func dropUpdated(info: DropInfo) -> DropProposal? | |
/// Tells the delegate a validated drop operation has exited the modified | |
/// view. | |
/// | |
/// The default implementation does nothing. | |
public func dropExited(info: DropInfo) | |
} | |
/// The current state of a drop. | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DropInfo { | |
/// The location of the drag in the coordinate space of the drop view. | |
public var location: CGPoint { get } | |
/// Indicates whether at least one item conforms to at least one of the | |
/// specified uniform type identifiers. | |
/// | |
/// - Parameter contentTypes: The uniform type identifiers to query for. | |
/// - Returns: Whether at least one item conforms to one of `contentTypes`. | |
@available(iOS 14.0, macOS 11.0, *) | |
public func hasItemsConforming(to contentTypes: [UTType]) -> Bool | |
/// Finds item providers that conform to at least one of the specified | |
/// uniform type identifiers. | |
/// | |
/// This function is only valid during the `performDrop()` action. | |
/// | |
/// - Parameter contentTypes: The uniform type identifiers to query for. | |
/// - Returns: The item providers that conforms to `contentTypes`. | |
@available(iOS 14.0, macOS 11.0, *) | |
public func itemProviders(for contentTypes: [UTType]) -> [NSItemProvider] | |
} | |
@available(iOS, introduced: 13.4, deprecated: 100000.0, message: "Provide `UTType`s as the `types` instead.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Provide `UTType`s as the `types` instead.") | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DropInfo { | |
/// Returns whether at least one item conforms to at least one of the | |
/// specified uniform type identifiers. | |
public func hasItemsConforming(to types: [String]) -> Bool | |
/// Returns an Array of items that each conform to at least one of the | |
/// specified uniform type identifiers. | |
/// | |
/// This function is only valid during the performDrop() action. | |
public func itemProviders(for types: [String]) -> [NSItemProvider] | |
} | |
/// Operation types that determine how a drag and drop session resolves when the | |
/// user drops a drag item. | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public enum DropOperation { | |
/// Cancel the drag operation and transfer no data. | |
case cancel | |
/// The drop activity is not allowed at this time or location. | |
case forbidden | |
/// Copy the data to the modified view. | |
case copy | |
/// Move the data represented by the drag items instead of copying it. | |
case move | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: DropOperation, b: DropOperation) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DropOperation : Equatable { | |
} | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension DropOperation : Hashable { | |
} | |
/// The behavior of a drop. | |
@available(iOS 13.4, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct DropProposal { | |
/// The drop operation that the drop proposes to perform. | |
public let operation: DropOperation | |
public init(operation: DropOperation) | |
} | |
/// An interface for a stored variable that updates an external property of a | |
/// view. | |
/// | |
/// The view gives values to these properties prior to recomputing the view's | |
/// ``View/body-swift.property``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol DynamicProperty { | |
/// Updates the underlying value of the stored value. | |
/// | |
/// SwiftUI calls this function before rendering a view's | |
/// ``View/body-swift.property`` to ensure the view has the most recent | |
/// value. | |
mutating func update() | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension DynamicProperty { | |
/// Updates the underlying value of the stored value. | |
/// | |
/// SwiftUI calls this function before rendering a view's | |
/// ``View/body-swift.property`` to ensure the view has the most recent | |
/// value. | |
public mutating func update() | |
} | |
/// A Dynamic Type size, which specifies how large scalable content should be. | |
/// | |
/// For more information about Dynamic Type sizes in iOS, see iOS Human Interface Guidelines > | |
/// [Dynamic Type Sizes](https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/typography/#dynamic-type-sizes). | |
/// For more information about Dynamic Type sizes in watchOS, see watchOS Human Interface Guidelines > | |
/// [Dynamic Type Sizes](https://developer.apple.com/design/human-interface-guidelines/watchos/visual/typography/#dynamic-type-sizes). | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public enum DynamicTypeSize : Hashable, Comparable, CaseIterable { | |
/// An extra small size. | |
case xSmall | |
/// A small size. | |
case small | |
/// A medium size. | |
case medium | |
/// A large size. | |
case large | |
/// An extra large size. | |
case xLarge | |
/// An extra extra large size. | |
case xxLarge | |
/// An extra extra extra large size. | |
case xxxLarge | |
/// The first accessibility size. | |
case accessibility1 | |
/// The second accessibility size. | |
case accessibility2 | |
/// The third accessibility size. | |
case accessibility3 | |
/// The fourth accessibility size. | |
case accessibility4 | |
/// The fifth accessibility size. | |
case accessibility5 | |
/// A Boolean value indicating whether the size is one that is associated | |
/// with accessibility. | |
public var isAccessibilitySize: Bool { get } | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: DynamicTypeSize, b: DynamicTypeSize) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// Returns a Boolean value indicating whether the value of the first | |
/// argument is less than that of the second argument. | |
/// | |
/// This function is the only requirement of the `Comparable` protocol. The | |
/// remainder of the relational operator functions are implemented by the | |
/// standard library for any type that conforms to `Comparable`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func < (a: DynamicTypeSize, b: DynamicTypeSize) -> Bool | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [DynamicTypeSize] | |
/// A collection of all values of this type. | |
public static var allCases: [DynamicTypeSize] { get } | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
extension DynamicTypeSize { | |
/// Create a Dynamic Type size from its `UIContentSizeCategory` equivalent. | |
@available(iOS 15.0, tvOS 15.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
public init?(_ uiSizeCategory: UIContentSizeCategory) | |
} | |
/// A type of view that generates views from an underlying collection of data. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol DynamicViewContent : View { | |
/// The type of the underlying collection of data. | |
associatedtype Data : Collection | |
/// The collection of underlying data. | |
var data: Self.Data { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension DynamicViewContent { | |
/// Sets the deletion action for the dynamic view. | |
/// | |
/// - Parameter action: The action that you want SwiftUI to perform when | |
/// elements in the view are deleted. SwiftUI passes a set of indices to the | |
/// closure that's relative to the dynamic view's underlying collection of | |
/// data. | |
/// | |
/// - Returns: A view that calls `action` when elements are deleted from the | |
/// original view. | |
@inlinable public func onDelete(perform action: ((IndexSet) -> Void)?) -> some DynamicViewContent | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension DynamicViewContent { | |
/// Sets the move action for the dynamic view. | |
/// | |
/// - Parameters: | |
/// - action: A closure that SwiftUI invokes when elements in the dynamic | |
/// view are moved. The closure takes two arguments that represent the | |
/// offset relative to the dynamic view's underlying collection of data. | |
/// Pass `nil` to disable the ability to move items. | |
/// | |
/// - Returns: A view that calls `action` when elements are moved within the | |
/// original view. | |
@inlinable public func onMove(perform action: ((IndexSet, Int) -> Void)?) -> some DynamicViewContent | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension DynamicViewContent { | |
/// Sets the insert action for the dynamic view. | |
/// | |
/// - Parameters: | |
/// - supportedContentTypes: An array of UTI types that the dynamic | |
/// view supports. | |
/// - action: A closure that SwiftUI invokes when elements are added to | |
/// the view. The closure takes two arguments: The first argument is the | |
/// offset relative to the dynamic view's underlying collection of data. | |
/// The second argument is an array of | |
/// <doc://com.apple.documentation/documentation/Foundation/NSItemProvider> items that | |
/// represents the data that you want to insert. | |
/// | |
/// - Returns: A view that calls `action` when elements are inserted into | |
/// the original view. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public func onInsert(of supportedContentTypes: [UTType], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent | |
/// Sets the insert action for the dynamic view. | |
/// | |
/// - Parameters: | |
/// - acceptedTypeIdentifiers: An array of UTI types that the dynamic | |
/// view supports. | |
/// - action: A closure that SwiftUI invokes when elements are added to | |
/// the view. The closure takes two arguments: The first argument is the | |
/// offset relative to the dynamic view's underlying collection of data. | |
/// The second argument is an array of `NSItemProvider` that represents | |
/// the data that you want to insert. | |
/// | |
/// - Returns: A view that calls `action` when elements are inserted into | |
/// the original view. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Provide `UTType`s as the `supportedContentTypes` instead.") | |
public func onInsert(of acceptedTypeIdentifiers: [String], perform action: @escaping (Int, [NSItemProvider]) -> Void) -> some DynamicViewContent | |
} | |
/// An enumeration to indicate one edge of a rectangle. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public enum Edge : Int8, CaseIterable { | |
case top | |
case leading | |
case bottom | |
case trailing | |
/// An efficient set of `Edge`s. | |
@frozen public struct Set : OptionSet { | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = Edge.Set | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: Int8 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
public init(rawValue: Int8) | |
public static let top: Edge.Set | |
public static let leading: Edge.Set | |
public static let bottom: Edge.Set | |
public static let trailing: Edge.Set | |
public static let all: Edge.Set | |
public static let horizontal: Edge.Set | |
public static let vertical: Edge.Set | |
/// Creates an instance containing just `e` | |
public init(_ e: Edge) | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = Edge.Set.Element | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int8 | |
} | |
/// Creates a new instance with the specified raw value. | |
/// | |
/// If there is no value of the type that corresponds with the specified raw | |
/// value, this initializer returns `nil`. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// print(PaperSize(rawValue: "Legal")) | |
/// // Prints "Optional("PaperSize.Legal")" | |
/// | |
/// print(PaperSize(rawValue: "Tabloid")) | |
/// // Prints "nil" | |
/// | |
/// - Parameter rawValue: The raw value to use for the new instance. | |
public init?(rawValue: Int8) | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [Edge] | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int8 | |
/// A collection of all values of this type. | |
public static var allCases: [Edge] { get } | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public var rawValue: Int8 { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Edge : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Edge : Hashable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Edge : RawRepresentable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Edge : Sendable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Edge.Set : Sendable { | |
} | |
/// The inset distances for the sides of a rectangle. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct EdgeInsets : Equatable { | |
public var top: CGFloat | |
public var leading: CGFloat | |
public var bottom: CGFloat | |
public var trailing: CGFloat | |
@inlinable public init(top: CGFloat, leading: CGFloat, bottom: CGFloat, trailing: CGFloat) | |
@inlinable public init() | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: EdgeInsets, b: EdgeInsets) -> Bool | |
} | |
extension EdgeInsets { | |
/// Create edge insets from the equivalent NSDirectionalEdgeInsets. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *) | |
@available(watchOS, unavailable) | |
public init(_ nsEdgeInsets: NSDirectionalEdgeInsets) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EdgeInsets : Animatable { | |
/// The type defining the data to animate. | |
public typealias AnimatableData = AnimatablePair<CGFloat, AnimatablePair<CGFloat, AnimatablePair<CGFloat, CGFloat>>> | |
/// The data to animate. | |
public var animatableData: EdgeInsets.AnimatableData | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EdgeInsets : Sendable { | |
} | |
/// A button that toggles the edit mode for the current edit scope. | |
/// | |
/// An Edit button toggles the ``EditMode`` for content within a container that | |
/// supports ``EditMode/active``. In the following example, an `EditButton` | |
/// placed inside a ``NavigationView`` supports editing of a ``List``: | |
/// | |
/// @State private var fruits = [ | |
/// "Apple", | |
/// "Banana", | |
/// "Papaya", | |
/// "Mango" | |
/// ] | |
/// | |
/// var body: some View { | |
/// NavigationView{ | |
/// List { | |
/// ForEach( | |
/// fruits, | |
/// id: \.self | |
/// ) { fruit in | |
/// Text(fruit) | |
/// } | |
/// .onDelete { self.deleteFruit(at :$0) } | |
/// .onMove { self.moveFruit(from: $0, to: $1) } | |
/// } | |
/// .navigationTitle("Fruits") | |
/// .toolbar { EditButton() } | |
/// } | |
/// } | |
/// | |
/// Because the list defines behaviors for | |
/// ``DynamicViewContent/onDelete(perform:)`` and | |
/// ``DynamicViewContent/onMove(perform:)``, the editable list displays the | |
/// delete and move UI when the user taps Edit, as seen in the | |
/// following screenshot. Also notice that the Edit button displays the title | |
/// "Done", because the list is in editing mode. | |
/// | |
/// ![A screenshot of an app with an navigation with an EditButton as its | |
/// right-side button, labeled Done to indicate it is active. Below the | |
/// navigation, a list labeled Fruits contains four members, each showing | |
/// its delete and move user interface | |
/// elements.](SwiftUI-EditButton-editingList.png) | |
/// | |
@available(iOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct EditButton : View { | |
/// Creates an Edit button instance. | |
public init() | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
/// The mode of a view indicating whether the user can edit its content. | |
@available(iOS 13.0, tvOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
public enum EditMode { | |
/// The view content cannot be edited. | |
case inactive | |
/// The view is in a temporary edit mode. | |
/// | |
/// The definition of temporary might vary by platform or specific control. | |
/// As an example, temporary edit mode may be engaged over the duration of a | |
/// swipe gesture. | |
case transient | |
/// The view content can be edited. | |
case active | |
/// Indicates whether a view is being edited. | |
public var isEditing: Bool { get } | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: EditMode, b: EditMode) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 13.0, tvOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EditMode : Equatable { | |
} | |
@available(iOS 13.0, tvOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EditMode : Hashable { | |
} | |
/// An ellipse aligned inside the frame of the view containing it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Ellipse : Shape { | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in rect: CGRect) -> Path | |
@inlinable public init() | |
/// The type defining the data to animate. | |
public typealias AnimatableData = EmptyAnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Ellipse : InsettableShape { | |
/// Returns `self` inset by `amount`. | |
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape | |
/// The type of the inset shape. | |
public typealias InsetShape = some InsettableShape | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Ellipse : Sendable { | |
} | |
/// A radial gradient that draws an ellipse. | |
/// | |
/// The gradient maps its coordinate space to the unit space square | |
/// in which its center and radii are defined, then stretches that | |
/// square to fill its bounding rect, possibly also stretching the | |
/// circular gradient to have elliptical contours. | |
/// | |
/// For example, an elliptical gradient centered on the view, filling | |
/// its bounds: | |
/// | |
/// EllipticalGradient(gradient: .init(colors: [.red, .yellow])) | |
/// | |
/// When using an elliptical gradient as a shape style, you can also use | |
/// ``ShapeStyle/ellipticalGradient(_:center:startRadiusFraction:endRadiusFraction:)``. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
@frozen public struct EllipticalGradient : ShapeStyle, View { | |
/// Creates an elliptical gradient. | |
/// | |
/// For example, an elliptical gradient centered on the top-leading | |
/// corner of the view: | |
/// | |
/// EllipticalGradient( | |
/// gradient: .init(colors: [.blue, .green]), | |
/// center: .topLeading, | |
/// startRadiusFraction: 0, | |
/// endRadiusFraction: 1) | |
/// | |
/// - Parameters: | |
/// - gradient: The colors and their parametric locations. | |
/// - center: The center of the circle, in [0, 1] coordinates. | |
/// - startRadiusFraction: The start radius value, as a fraction | |
/// between zero and one. Zero maps to the center point, one | |
/// maps to the diameter of the unit circle. | |
/// - endRadiusFraction: The end radius value, as a fraction | |
/// between zero and one. Zero maps to the center point, one | |
/// maps to the diameter of the unit circle. | |
public init(gradient: Gradient, center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) | |
/// Creates an elliptical gradient from a collection of colors. | |
/// | |
/// For example, an elliptical gradient centered on the top-leading | |
/// corner of the view: | |
/// | |
/// EllipticalGradient( | |
/// colors: [.blue, .green], | |
/// center: .topLeading, | |
/// startRadiusFraction: 0, | |
/// endRadiusFraction: 1) | |
/// | |
/// - Parameters: | |
/// - colors: The colors, evenly distributed throughout the gradient. | |
/// - center: The center of the circle, in [0, 1] coordinates. | |
/// - startRadiusFraction: The start radius value, as a fraction | |
/// between zero and one. Zero maps to the center point, one | |
/// maps to the diameter of the unit circle. | |
/// - endRadiusFraction: The end radius value, as a fraction | |
/// between zero and one. Zero maps to the center point, one | |
/// maps to the diameter of the unit circle. | |
public init(colors: [Color], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) | |
/// Creates an elliptical gradient from a collection of color stops. | |
/// | |
/// For example, an elliptical gradient centered on the top-leading | |
/// corner of the view, with some extra green area: | |
/// | |
/// EllipticalGradient( | |
/// stops: [ | |
/// .init(color: .blue, location: 0.0), | |
/// .init(color: .green, location: 0.9), | |
/// .init(color: .green, location: 1.0), | |
/// ], | |
/// center: .topLeading, | |
/// startRadiusFraction: 0, | |
/// endRadiusFraction: 1) | |
/// | |
/// - Parameters: | |
/// - stops: The colors and their parametric locations. | |
/// - center: The center of the circle, in [0, 1] coordinates. | |
/// - startRadiusFraction: The start radius value, as a fraction | |
/// between zero and one. Zero maps to the center point, one | |
/// maps to the diameter of the unit circle. | |
/// - endRadiusFraction: The end radius value, as a fraction | |
/// between zero and one. Zero maps to the center point, one | |
/// maps to the diameter of the unit circle. | |
public init(stops: [Gradient.Stop], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
/// An empty type for animatable data. | |
/// | |
/// This type is suitable for use as the `animatableData` property of | |
/// types that do not have any animatable properties. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct EmptyAnimatableData : VectorArithmetic { | |
@inlinable public init() | |
/// The zero value. | |
/// | |
/// Zero is the identity element for addition. For any value, | |
/// `x + .zero == x` and `.zero + x == x`. | |
@inlinable public static var zero: EmptyAnimatableData { get } | |
/// Adds two values and stores the result in the left-hand-side variable. | |
/// | |
/// - Parameters: | |
/// - lhs: The first value to add. | |
/// - rhs: The second value to add. | |
@inlinable public static func += (lhs: inout EmptyAnimatableData, rhs: EmptyAnimatableData) | |
/// Subtracts the second value from the first and stores the difference in the | |
/// left-hand-side variable. | |
/// | |
/// - Parameters: | |
/// - lhs: A numeric value. | |
/// - rhs: The value to subtract from `lhs`. | |
@inlinable public static func -= (lhs: inout EmptyAnimatableData, rhs: EmptyAnimatableData) | |
/// Adds two values and produces their sum. | |
/// | |
/// The addition operator (`+`) calculates the sum of its two arguments. For | |
/// example: | |
/// | |
/// 1 + 2 // 3 | |
/// -10 + 15 // 5 | |
/// -15 + -5 // -20 | |
/// 21.5 + 3.25 // 24.75 | |
/// | |
/// You cannot use `+` with arguments of different types. To add values of | |
/// different types, convert one of the values to the other value's type. | |
/// | |
/// let x: Int8 = 21 | |
/// let y: Int = 1000000 | |
/// Int(x) + y // 1000021 | |
/// | |
/// - Parameters: | |
/// - lhs: The first value to add. | |
/// - rhs: The second value to add. | |
@inlinable public static func + (lhs: EmptyAnimatableData, rhs: EmptyAnimatableData) -> EmptyAnimatableData | |
/// Subtracts one value from another and produces their difference. | |
/// | |
/// The subtraction operator (`-`) calculates the difference of its two | |
/// arguments. For example: | |
/// | |
/// 8 - 3 // 5 | |
/// -10 - 5 // -15 | |
/// 100 - -5 // 105 | |
/// 10.5 - 100.0 // -89.5 | |
/// | |
/// You cannot use `-` with arguments of different types. To subtract values | |
/// of different types, convert one of the values to the other value's type. | |
/// | |
/// let x: UInt8 = 21 | |
/// let y: UInt = 1000000 | |
/// y - UInt(x) // 999979 | |
/// | |
/// - Parameters: | |
/// - lhs: A numeric value. | |
/// - rhs: The value to subtract from `lhs`. | |
@inlinable public static func - (lhs: EmptyAnimatableData, rhs: EmptyAnimatableData) -> EmptyAnimatableData | |
/// Multiplies each component of this value by the given value. | |
@inlinable public mutating func scale(by rhs: Double) | |
/// The dot-product of this animatable data instance with itself. | |
@inlinable public var magnitudeSquared: Double { get } | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: EmptyAnimatableData, b: EmptyAnimatableData) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EmptyAnimatableData : Sendable { | |
} | |
/// An empty group of commands. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct EmptyCommands : Commands { | |
/// Creates an empty command hierarchy. | |
public init() | |
/// The type of commands that represents the body of this command hierarchy. | |
/// | |
/// When you create custom commands, Swift infers this type from your | |
/// implementation of the required ``SwiftUI/Commands/body-swift.property`` | |
/// property. | |
public typealias Body = Never | |
} | |
/// An empty, or identity, modifier, used during development to switch | |
/// modifiers at compile time. | |
/// | |
/// Use the empty modifier to switch modifiers at compile time during | |
/// development. In the example below, in a debug build the ``Text`` | |
/// view inside `ContentView` has a yellow background and a red border. | |
/// A non-debug build reflects the default system, or container supplied | |
/// appearance. | |
/// | |
/// struct EmphasizedLayout: ViewModifier { | |
/// func body(content: Content) -> some View { | |
/// content | |
/// .background(Color.yellow) | |
/// .border(Color.red) | |
/// } | |
/// } | |
/// | |
/// struct ContentView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// .modifier(modifier) | |
/// } | |
/// | |
/// var modifier: some ViewModifier { | |
/// #if DEBUG | |
/// return EmphasizedLayout() | |
/// #else | |
/// return EmptyModifier() | |
/// #endif | |
/// } | |
/// } | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct EmptyModifier : ViewModifier { | |
public static let identity: EmptyModifier | |
/// The type of view representing the body. | |
public typealias Body = Never | |
@inlinable public init() | |
/// Gets the current body of the caller. | |
/// | |
/// `content` is a proxy for the view that will have the modifier | |
/// represented by `Self` applied to it. | |
public func body(content: EmptyModifier.Content) -> EmptyModifier.Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EmptyModifier : Sendable { | |
} | |
/// A view that doesn't contain any content. | |
/// | |
/// You will rarely, if ever, need to create an `EmptyView` directly. Instead, | |
/// `EmptyView` represents the absence of a view. | |
/// | |
/// SwiftUI uses `EmptyView` in situations where a SwiftUI view type defines one | |
/// or more child views with generic parameters, and allows the child views to | |
/// be absent. When absent, the child view's type in the generic type parameter | |
/// is `EmptyView`. | |
/// | |
/// The following example creates an indeterminate ``ProgressView`` without | |
/// a label. The ``ProgressView`` type declares two generic parameters, | |
/// `Label` and `CurrentValueLabel`, for the types used by its subviews. | |
/// When both subviews are absent, like they are here, the resulting type is | |
/// `ProgressView<EmptyView, EmptyView>`, as indicated by the example's output: | |
/// | |
/// let progressView = ProgressView() | |
/// print("\(type(of:progressView))") | |
/// // Prints: ProgressView<EmptyView, EmptyView> | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct EmptyView : View { | |
/// Creates an empty view. | |
@inlinable public init() | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EmptyView : Sendable { | |
} | |
/// An empty widget configuration. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
@frozen public struct EmptyWidgetConfiguration : WidgetConfiguration { | |
@inlinable public init() | |
/// The type of widget configuration representing the body of | |
/// this configuration. | |
/// | |
/// When you create a custom widget, Swift infers this type from your | |
/// implementation of the required `body` property. | |
public typealias Body = Never | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EmptyWidgetConfiguration : Sendable { | |
} | |
/// Enables text selection by the user. | |
/// | |
/// Do not use this type directly. Instead, use ``TextSelectability/enabled``. | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct EnabledTextSelectability : TextSelectability { | |
/// Whether text allows selection or not. | |
/// | |
/// This should produce a constant value that is not affected by global | |
/// state. | |
public static let allowsSelection: Bool | |
} | |
/// A property wrapper that reads a value from a view's environment. | |
/// | |
/// Use the `Environment` property wrapper to read a value | |
/// stored in a view's environment. Indicate the value to read using an | |
/// ``EnvironmentValues`` key path in the property declaration. For example, you | |
/// can create a property that reads the color scheme of the current | |
/// view using the key path of the ``EnvironmentValues/colorScheme`` | |
/// property: | |
/// | |
/// @Environment(\.colorScheme) var colorScheme: ColorScheme | |
/// | |
/// You can condition a view's content on the associated value, which | |
/// you read from the declared property's ``wrappedValue``. As with any property | |
/// wrapper, you access the wrapped value by directly referring to the property: | |
/// | |
/// if colorScheme == .dark { // Checks the wrapped value. | |
/// DarkContent() | |
/// } else { | |
/// LightContent() | |
/// } | |
/// | |
/// If the value changes, SwiftUI updates any parts of your view that depend on | |
/// the value. For example, that might happen in the above example if the user | |
/// changes the Appearance settings. | |
/// | |
/// You can use this property wrapper to read --- but not set --- an environment | |
/// value. SwiftUI updates some environment values automatically based on system | |
/// settings and provides reasonable defaults for others. You can override some | |
/// of these, as well as set custom environment values that you define, | |
/// using the ``View/environment(_:_:)`` view modifier. | |
/// | |
/// For the complete list of environment values provided by SwiftUI, see the | |
/// properties of the ``EnvironmentValues`` structure. For information about | |
/// creating custom environment values, see the ``EnvironmentKey`` protocol. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen @propertyWrapper public struct Environment<Value> : DynamicProperty { | |
/// Creates an environment property to read the specified key path. | |
/// | |
/// Don’t call this initializer directly. Instead, declare a property | |
/// with the ``Environment`` property wrapper, and provide the key path of | |
/// the environment value that the property should reflect: | |
/// | |
/// struct MyView: View { | |
/// @Environment(\.colorScheme) var colorScheme: ColorScheme | |
/// | |
/// // ... | |
/// } | |
/// | |
/// SwiftUI automatically updates any parts of `MyView` that depend on | |
/// the property when the associated environment value changes. | |
/// You can't modify the environment value using a property like this. | |
/// Instead, use the ``View/environment(_:_:)`` view modifier on a view to | |
/// set a value for a view hierarchy. | |
/// | |
/// - Parameter keyPath: A key path to a specific resulting value. | |
@inlinable public init(_ keyPath: KeyPath<EnvironmentValues, Value>) | |
/// The current value of the environment property. | |
/// | |
/// The wrapped value property provides primary access to the value's data. | |
/// However, you don't access `wrappedValue` directly. Instead, you read the | |
/// property variable created with the ``Environment`` property wrapper: | |
/// | |
/// @Environment(\.colorScheme) var colorScheme: ColorScheme | |
/// | |
/// var body: some View { | |
/// if colorScheme == .dark { | |
/// DarkContent() | |
/// } else { | |
/// LightContent() | |
/// } | |
/// } | |
/// | |
@inlinable public var wrappedValue: Value { get } | |
} | |
/// A key for accessing values in the environment. | |
/// | |
/// You can create custom environment values by extending the | |
/// ``EnvironmentValues`` structure with new properties. | |
/// First declare a new environment key type and specify a value for the | |
/// required ``defaultValue`` property: | |
/// | |
/// private struct MyEnvironmentKey: EnvironmentKey { | |
/// static let defaultValue: String = "Default value" | |
/// } | |
/// | |
/// The Swift compiler automatically infers the associated ``Value`` type as the | |
/// type you specify for the default value. Then use the key to define a new | |
/// environment value property: | |
/// | |
/// extension EnvironmentValues { | |
/// var myCustomValue: String { | |
/// get { self[MyEnvironmentKey.self] } | |
/// set { self[MyEnvironmentKey.self] = newValue } | |
/// } | |
/// } | |
/// | |
/// Clients of your environment value never use the key directly. | |
/// Instead, they use the key path of your custom environment value property. | |
/// To set the environment value for a view and all its subviews, add the | |
/// ``View/environment(_:_:)`` view modifier to that view: | |
/// | |
/// MyView() | |
/// .environment(\.myCustomValue, "Another string") | |
/// | |
/// As a convenience, you can also define a dedicated view modifier to | |
/// apply this environment value: | |
/// | |
/// extension View { | |
/// func myCustomValue(_ myCustomValue: String) -> some View { | |
/// environment(\.myCustomValue, myCustomValue) | |
/// } | |
/// } | |
/// | |
/// This improves clarity at the call site: | |
/// | |
/// MyView() | |
/// .myCustomValue("Another string") | |
/// | |
/// To read the value from inside `MyView` or one of its descendants, use the | |
/// ``Environment`` property wrapper: | |
/// | |
/// struct MyView: View { | |
/// @Environment(\.myCustomValue) var customValue: String | |
/// | |
/// var body: some View { | |
/// Text(customValue) // Displays "Another value". | |
/// } | |
/// } | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol EnvironmentKey { | |
/// The associated type representing the type of the environment key's | |
/// value. | |
associatedtype Value | |
/// The default value for the environment key. | |
static var defaultValue: Self.Value { get } | |
} | |
/// A property wrapper type for an observable object supplied by a parent or | |
/// ancestor view. | |
/// | |
/// An environment object invalidates the current view whenever the observable | |
/// object changes. If you declare a property as an environment object, be sure | |
/// to set a corresponding model object on an ancestor view by calling its | |
/// ``View/environmentObject(_:)`` modifier. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen @propertyWrapper public struct EnvironmentObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject { | |
/// A wrapper of the underlying environment object that can create bindings | |
/// to its properties using dynamic member lookup. | |
@dynamicMemberLookup @frozen public struct Wrapper { | |
/// Returns a binding to the resulting value of a given key path. | |
/// | |
/// - Parameter keyPath: A key path to a specific resulting value. | |
/// | |
/// - Returns: A new binding. | |
public subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<ObjectType, Subject>) -> Binding<Subject> { get } | |
} | |
/// The underlying value referenced by the environment object. | |
/// | |
/// This property provides primary access to the value's data. However, you | |
/// don't access `wrappedValue` directly. Instead, you use the property | |
/// variable created with the ``EnvironmentObject`` attribute. | |
/// | |
/// When a mutable value changes, the new value is immediately available. | |
/// However, a view displaying the value is updated asynchronously and may | |
/// not show the new value immediately. | |
@inlinable public var wrappedValue: ObjectType { get } | |
/// A projection of the environment object that creates bindings to its | |
/// properties using dynamic member lookup. | |
/// | |
/// Use the projected value to pass an environment object down a view | |
/// hierarchy. | |
public var projectedValue: EnvironmentObject<ObjectType>.Wrapper { get } | |
/// Creates an environment object. | |
public init() | |
} | |
/// A collection of environment values propagated through a view hierarchy. | |
/// | |
/// SwiftUI exposes a collection of values to your app's views in an | |
/// `EnvironmentValues` structure. To read a value from the structure, | |
/// declare a property using the ``Environment`` property wrapper and | |
/// specify the value's key path. For example, you can read the current locale: | |
/// | |
/// @Environment(\.locale) var locale: Locale | |
/// | |
/// Use the property you declare to dynamically control a view's layout. | |
/// SwiftUI automatically sets or updates many environment values, like | |
/// ``EnvironmentValues/pixelLength``, ``EnvironmentValues/scenePhase``, or | |
/// ``EnvironmentValues/locale``, based on device characteristics, system state, | |
/// or user settings. For others, like ``EnvironmentValues/lineLimit``, SwiftUI | |
/// provides a reasonable default value. | |
/// | |
/// You can set or override some values using the ``View/environment(_:_:)`` | |
/// view modifier: | |
/// | |
/// MyView() | |
/// .environment(\.lineLimit, 2) | |
/// | |
/// The value that you set affects the environment for the view that you modify | |
/// --- including its descendants in the view hierarchy --- but only up to the | |
/// point where you apply a different environment modifier. | |
/// | |
/// SwiftUI provides dedicated view modifiers for setting some values, which | |
/// typically makes your code easier to read. For example, rather than setting | |
/// the ``EnvironmentValues/lineLimit`` value directly, as in the previous | |
/// example, you should instead use the ``View/lineLimit(_:)`` modifier: | |
/// | |
/// MyView() | |
/// .lineLimit(2) | |
/// | |
/// In some cases, using a dedicated view modifier provides additional | |
/// functionality. For example, you must use the | |
/// ``View/preferredColorScheme(_:)`` modifier rather than setting | |
/// ``EnvironmentValues/colorScheme`` directly to ensure that the new | |
/// value propagates up to the presenting container when presenting a view | |
/// like a popover: | |
/// | |
/// MyView() | |
/// .popover(isPresented: $isPopped) { | |
/// PopoverContent() | |
/// .preferredColorScheme(.dark) | |
/// } | |
/// | |
/// Create custom environment values by defining a type that | |
/// conforms to the ``EnvironmentKey`` protocol, and then extending the | |
/// environment values structure with a new property. Use your key to get and | |
/// set the value, and provide a dedicated modifier for clients to use when | |
/// setting the value: | |
/// | |
/// private struct MyEnvironmentKey: EnvironmentKey { | |
/// static let defaultValue: String = "Default value" | |
/// } | |
/// | |
/// extension EnvironmentValues { | |
/// var myCustomValue: String { | |
/// get { self[MyEnvironmentKey.self] } | |
/// set { self[MyEnvironmentKey.self] = newValue } | |
/// } | |
/// } | |
/// | |
/// extension View { | |
/// func myCustomValue(_ myCustomValue: String) -> some View { | |
/// environment(\.myCustomValue, myCustomValue) | |
/// } | |
/// } | |
/// | |
/// Clients of your value then access the value in the usual way, reading it | |
/// with the ``Environment`` property wrapper, and setting it with the | |
/// `myCustomValue` view modifier. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct EnvironmentValues : CustomStringConvertible { | |
/// Creates an environment values instance. | |
/// | |
/// You don't typically create an instance of ``EnvironmentValues`` | |
/// directly. Doing so would provide access only to default values that | |
/// don't update based on system settings or device characteristics. | |
/// Instead, you rely on an environment values' instance | |
/// that SwiftUI manages for you when you use the ``Environment`` | |
/// property wrapper and the ``View/environment(_:_:)`` view modifier. | |
public init() | |
/// Accesses the environment value associated with a custom key. | |
/// | |
/// Create custom environment values by defining a key | |
/// that conforms to the ``EnvironmentKey`` protocol, and then using that | |
/// key with the subscript operator of the ``EnvironmentValues`` structure | |
/// to get and set a value for that key: | |
/// | |
/// private struct MyEnvironmentKey: EnvironmentKey { | |
/// static let defaultValue: String = "Default value" | |
/// } | |
/// | |
/// extension EnvironmentValues { | |
/// var myCustomValue: String { | |
/// get { self[MyEnvironmentKey.self] } | |
/// set { self[MyEnvironmentKey.self] = newValue } | |
/// } | |
/// } | |
/// | |
/// You use custom environment values the same way you use system-provided | |
/// values, setting a value with the ``View/environment(_:_:)`` view | |
/// modifier, and reading values with the ``Environment`` property wrapper. | |
/// You can also provide a dedicated view modifier as a convenience for | |
/// setting the value: | |
/// | |
/// extension View { | |
/// func myCustomValue(_ myCustomValue: String) -> some View { | |
/// environment(\.myCustomValue, myCustomValue) | |
/// } | |
/// } | |
/// | |
public subscript<K>(key: K.Type) -> K.Value where K : EnvironmentKey | |
/// A string that represents the contents of the environment values | |
/// instance. | |
public var description: String { get } | |
} | |
extension EnvironmentValues { | |
/// A Boolean value that determines whether the view hierarchy has | |
/// auto-correction enabled. | |
/// | |
/// When the value is `nil`, SwiftUI uses the system default. The default | |
/// value is `nil`. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 8.0, *) | |
public var disableAutocorrection: Bool? | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// The symbol variant to use in this environment. | |
/// | |
/// You set this environment value indirectly by using the | |
/// ``View/symbolVariant(_:)`` view modifier. However, you access the | |
/// environment variable directly using the ``View/environment(_:_:)`` | |
/// modifier. Do this when you want to use the ``SymbolVariants/none`` | |
/// variant to ignore the value that's already in the environment: | |
/// | |
/// HStack { | |
/// Image(systemName: "heart") | |
/// Image(systemName: "heart") | |
/// .environment(\.symbolVariants, .none) | |
/// } | |
/// .symbolVariant(.fill) | |
/// | |
/// ![A screenshot of two heart symbols. The first is filled while the | |
/// second is outlined.](SymbolVariants-none-1) | |
public var symbolVariants: SymbolVariants | |
} | |
extension EnvironmentValues { | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "dynamicTypeSize") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "dynamicTypeSize") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "dynamicTypeSize") | |
public var sizeCategory: ContentSizeCategory | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
public var managedObjectContext: NSManagedObjectContext | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// The undo manager used to register a view's undo operations. | |
/// | |
/// This value is `nil` when the environment represents a context that | |
/// doesn't support undo and redo operations. You can skip registration of | |
/// an undo operation when this value is `nil`. | |
public var undoManager: UndoManager? { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// The layout direction associated with the current environment. | |
/// | |
/// Use this value to determine whether the environment uses a left-to-right | |
/// or right-to-left orientation. | |
public var layoutDirection: LayoutDirection | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension EnvironmentValues { | |
/// The current redaction reasons applied to the view hierarchy. | |
public var redactionReasons: RedactionReasons | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension EnvironmentValues { | |
/// The current phase of the scene. | |
/// | |
/// The system sets this value to provide an indication of the | |
/// operational state of a scene or collection of scenes. The exact | |
/// meaning depends on where you access the value. For more information, | |
/// see ``ScenePhase``. | |
public var scenePhase: ScenePhase | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// The default minimum height of a row in a list. | |
public var defaultMinListRowHeight: CGFloat | |
/// The default minimum height of a header in a list. | |
/// | |
/// When this value is `nil`, the system chooses the appropriate height. The | |
/// default is `nil`. | |
public var defaultMinListHeaderHeight: CGFloat? | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// The prominence to apply to controls within a view. | |
/// | |
/// The default is ``Prominence/standard``. | |
public var controlProminence: Prominence | |
/// The prominence to apply to section headers within a view. | |
/// | |
/// The default is ``Prominence/standard``. | |
public var headerProminence: Prominence | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EnvironmentValues { | |
/// The menu indicator visibility to apply to controls within a view. | |
public var menuIndicatorVisibility: Visibility | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// A Boolean value that indicates whether the view associated with this | |
/// environment allows user interaction. | |
/// | |
/// The default value is `true`. | |
public var isEnabled: Bool | |
} | |
extension EnvironmentValues { | |
/// Returns whether the nearest focusable ancestor has focus. | |
/// | |
/// If there is no focusable ancestor, the value is `false`. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public var isFocused: Bool { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// The default font of this environment. | |
public var font: Font? | |
/// The display scale of this environment. | |
public var displayScale: CGFloat | |
/// The image scale for this environment. | |
@available(macOS 11.0, *) | |
public var imageScale: Image.Scale | |
/// The size of a pixel on the screen. | |
/// | |
/// This value is usually equal to `1` divided by | |
/// ``EnvironmentValues/displayScale``. | |
public var pixelLength: CGFloat { get } | |
/// The font weight to apply to text. | |
/// | |
/// This value reflects the value of the Bold Text display setting found in | |
/// the Accessibility settings. | |
public var legibilityWeight: LegibilityWeight? | |
/// The current locale that views should use. | |
public var locale: Locale | |
/// The current calendar that views should use when handling dates. | |
public var calendar: Calendar | |
/// The current time zone that views should use when handling dates. | |
public var timeZone: TimeZone | |
} | |
@available(iOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EnvironmentValues { | |
/// The horizontal size class of this environment. | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public var horizontalSizeClass: UserInterfaceSizeClass? | |
/// The vertical size class of this environment. | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public var verticalSizeClass: UserInterfaceSizeClass? | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// A Boolean value that indicates whether the user has enabled an assistive | |
/// technology. | |
public var accessibilityEnabled: Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// Whether the system preference for Differentiate without Color is enabled. | |
/// | |
/// If this is true, UI should not convey information using color alone | |
/// and instead should use shapes or glyphs to convey information. | |
public var accessibilityDifferentiateWithoutColor: Bool { get } | |
/// Whether the system preference for Reduce Transparency is enabled. | |
/// | |
/// If this property's value is true, UI (mainly window) backgrounds should | |
/// not be semi-transparent; they should be opaque. | |
public var accessibilityReduceTransparency: Bool { get } | |
/// Whether the system preference for Reduce Motion is enabled. | |
/// | |
/// If this property's value is true, UI should avoid large animations, | |
/// especially those that simulate the third dimension. | |
public var accessibilityReduceMotion: Bool { get } | |
/// Whether the system preference for Invert Colors is enabled. | |
/// | |
/// If this property's value is true then the display will be inverted. | |
/// In these cases it may be needed for UI drawing to be adjusted to in | |
/// order to display optimally when inverted. | |
public var accessibilityInvertColors: Bool { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension EnvironmentValues { | |
/// Whether the system preference for Show Button Shapes is enabled. | |
/// | |
/// If this property's value is true, interactive custom controls | |
/// such as buttons should be drawn in such a way that their edges | |
/// and borders are clearly visible. | |
public var accessibilityShowButtonShapes: Bool { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// A Boolean value that indicates whether the VoiceOver screen reader is in use. | |
/// | |
/// The state changes as the user turns on or off the VoiceOver screen reader. | |
public var accessibilityVoiceOverEnabled: Bool { get } | |
/// A Boolean value that indicates whether the Switch Control motor accessibility feature is in use. | |
/// | |
/// The state changes as the user turns on or off the Switch Control feature. | |
public var accessibilitySwitchControlEnabled: Bool { get } | |
} | |
extension EnvironmentValues { | |
/// The current Dynamic Type size. | |
/// | |
/// This value changes as the user's chosen Dynamic Type size changes. The | |
/// default value is device-dependent. | |
/// | |
/// On macOS, this value cannot be changed by users and does not affect the | |
/// text size. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public var dynamicTypeSize: DynamicTypeSize | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// The current symbol rendering mode, or `nil` denoting that the | |
/// mode is picked automatically using the current image and | |
/// foreground style as parameters. | |
public var symbolRenderingMode: SymbolRenderingMode? | |
} | |
extension EnvironmentValues { | |
/// Whether the user is currently interacting with a search field that has | |
/// been placed by a surrounding searchable modifier. | |
/// | |
/// struct ContentView: View { | |
/// @State var text = "" | |
/// | |
/// var body: some View { | |
/// SearchReadingView() | |
/// .searchable(text: $text) | |
/// } | |
/// } | |
/// | |
/// struct SearchReadingView: View { | |
/// @Environment(\.isSearching) var isSearching | |
/// | |
/// var body: some View { | |
/// if isSearching { | |
/// Text("Searching!") | |
/// } else { | |
/// Text("Not searching.") | |
/// } | |
/// } | |
/// | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public var isSearching: Bool { get } | |
/// Asks the system to dismiss the current search interaction. | |
/// | |
/// When able, this will cause ``EnvironmentValues/isSearching`` to | |
/// become false, any search text to be cleared, and the search field to | |
/// lose focus. | |
/// | |
/// NavigationView { | |
/// MyList() | |
/// .searchable(text: $text) | |
/// } | |
/// | |
/// struct MyList: View { | |
/// @State private var isPresented = false | |
/// @Environment(\.isSearching) private var isSearching | |
/// | |
/// var body: some View { | |
/// Text("Main List") | |
/// .frame(maxWidth: .infinity, maxHeight: .infinity) | |
/// .overlay { | |
/// if isSearching { | |
/// Button { | |
/// isPresented = true | |
/// } label: { | |
/// Text("Present") | |
/// .frame( | |
/// maxWidth: .infinity, | |
/// maxHeight: .infinity | |
/// ) | |
/// .background() | |
/// } | |
/// .sheet(isPresented: $isPresented) { | |
/// NavigationView { | |
/// DetailView() | |
/// } | |
/// } | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
/// struct DetailView: View { | |
/// @Environment(\.dismiss) private var dismiss | |
/// @Environment(\.dismissSearch) private var dismissSearch | |
/// | |
/// var body: some View { | |
/// Text("Detail Content") | |
/// .toolbar { | |
/// Button("Add") { | |
/// dismiss() | |
/// dismissSearch() | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public var dismissSearch: DismissSearchAction { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// A refresh action stored in a view's environment. | |
/// | |
/// If you design a custom view that can support a refresh operation, | |
/// like a view that displays a collection of model objects stored on a server, | |
/// use the existence of an action in the view's environment | |
/// to change the view's appearance and behavior to provide | |
/// a way for the user to initiate the refresh action. An action of `nil` | |
/// indicates that the view doesn't need to support refresh. | |
/// | |
/// Set a value for this action on a view using the | |
/// ``View/refreshable(action:)`` modifier. | |
public var refresh: RefreshAction? { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension EnvironmentValues { | |
/// Opens a URL using the appropriate system service. | |
public var openURL: OpenURLAction { get } | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EnvironmentValues { | |
/// The keyboard shortcut that buttons in this environment will be triggered | |
/// with. | |
/// | |
/// This is particularly useful in button styles when a button's appearance | |
/// depends on the shortcut associated with it. On macOS, for example, when | |
/// a button is bound to the Return key, it is typically drawn with a | |
/// special emphasis. This happens automatically when using the built-in | |
/// button styles, and can be implemented manually in custom styles using | |
/// this environment key: | |
/// | |
/// private struct MyButtonStyle: ButtonStyle { | |
/// @Environment(\.keyboardShortcut) | |
/// private var shortcut: KeyboardShortcut? | |
/// | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// let labelFont = Font.body | |
/// .weight(shortcut == .defaultAction ? .bold : .regular) | |
/// configuration.label | |
/// .font(labelFont) | |
/// } | |
/// } | |
/// | |
/// If no keyboard shortcut has been applied to the view or its ancestor, | |
/// then the environment value will be `nil`. | |
public var keyboardShortcut: KeyboardShortcut? { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// Dismisses the current presentation. | |
public var dismiss: DismissAction { get } | |
/// A Boolean value that indicates whether the view associated with this | |
/// environment is currently being presented. | |
public var isPresented: Bool { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// A value that indicates how text instance aligns its lines when the | |
/// content wraps or contains newlines. | |
/// | |
/// Use alignment parameters on a parent view to align ``Text`` with respect | |
/// to its parent. Because the horizontal bounds of ``TextField`` never | |
/// exceed its graphical extent, this value has little to no effect on | |
/// single-line text. | |
public var multilineTextAlignment: TextAlignment | |
/// A value that indicates how the layout truncates the last line of text to | |
/// fit into the available space. | |
/// | |
/// The default value is ``Text/TruncationMode/tail``. | |
public var truncationMode: Text.TruncationMode | |
/// The distance in points between the bottom of one line fragment and the | |
/// top of the next. | |
/// | |
/// This value is always nonnegative. | |
public var lineSpacing: CGFloat | |
/// A Boolean value that indicates whether inter-character spacing should | |
/// tighten to fit the text into the available space. | |
/// | |
/// The default value is `false`. | |
public var allowsTightening: Bool | |
/// The maximum number of lines that text can occupy in a view. | |
/// | |
/// The maximum number of lines is `1` if the value is less than `1`. If the | |
/// value is `nil`, the text uses as many lines as required. The default is | |
/// `nil`. | |
public var lineLimit: Int? | |
/// The minimum permissible proportion to shrink the font size to fit | |
/// the text into the available space. | |
/// | |
/// In the example below, a label with a `minimumScaleFactor` of `0.5` | |
/// draws its text in a font size as small as half of the actual font if | |
/// needed to fit into the space next to the text input field: | |
/// | |
/// HStack { | |
/// Text("This is a very long label:") | |
/// .lineLimit(1) | |
/// .minimumScaleFactor(0.5) | |
/// TextField("My Long Text Field", text: $myTextField) | |
/// .frame(width: 250, height: 50, alignment: .center) | |
/// } | |
/// | |
/// ![A screenshot showing the effects of setting the minimumScaleFactor on | |
/// the text in a view](SwiftUI-view-minimumScaleFactor.png) | |
/// | |
/// You can set the minimum scale factor to any value greater than `0` and | |
/// less than or equal to `1`. The default value is `1`. | |
/// | |
/// SwiftUI uses this value to shrink text that doesn't fit in a view when | |
/// it's okay to shrink the text. For example, a label with a | |
/// `minimumScaleFactor` of `0.5` draws its text in a font size as small as | |
/// half the actual font if needed. | |
public var minimumScaleFactor: CGFloat | |
/// A stylistic override to transform the case of `Text` when displayed, | |
/// using the environment's locale. | |
/// | |
/// The default value is `nil`, displaying the `Text` without any case | |
/// changes. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public var textCase: Text.Case? | |
} | |
@available(iOS 13.0, tvOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EnvironmentValues { | |
/// The mode indicating whether the user can edit the contents of a view | |
/// associated with this environment. | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
public var editMode: Binding<EditMode>? | |
} | |
@available(iOS 15.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension EnvironmentValues { | |
/// The size to apply to controls within a view. | |
/// | |
/// The default is ``ControlSize/regular``. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public var controlSize: ControlSize | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EnvironmentValues { | |
/// A binding to the current presentation mode of the view associated with | |
/// this environment. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use isPresented or dismiss") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use isPresented or dismiss") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use isPresented or dismiss") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use isPresented or dismiss") | |
public var presentationMode: Binding<PresentationMode> { get } | |
} | |
extension EnvironmentValues { | |
/// The color scheme of this environment. | |
/// | |
/// When writing custom drawing code that depends on the current color | |
/// scheme, you should also consider the | |
/// ``EnvironmentValues/colorSchemeContrast`` property. You can specify | |
/// images and colors in asset catalogs according to either the | |
/// ``ColorScheme/light`` or ``ColorScheme/dark`` color scheme, as well as | |
/// standard or increased contrast. The correct image or color displays | |
/// automatically for the current environment. | |
/// | |
/// You only need to check `colorScheme` and | |
/// ``EnvironmentValues/colorSchemeContrast`` for custom drawing if the | |
/// differences go beyond images and colors. | |
/// | |
/// Setting the `colorScheme` environment value directly is an advanced use | |
/// case, as it changes the color scheme of the contained views but *not* of | |
/// the container. Instead, consider using the | |
/// ``View/preferredColorScheme(_:)`` modifier, which propagates to the | |
/// presentation containing the view. | |
public var colorScheme: ColorScheme | |
/// The contrast associated with the color scheme of this environment. | |
public var colorSchemeContrast: ColorSchemeContrast { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension EnvironmentValues { | |
/// The material underneath the current view. | |
/// | |
/// This value is `nil` if the current background isn't one of the standard | |
/// materials. If you set a material, the standard content styles enable | |
/// their vibrant rendering modes. | |
/// | |
/// You set this value by calling one of the background modifiers that takes | |
/// a ``ShapeStyle``, like ``View/background(_:ignoresSafeAreaEdges:)`` | |
/// or ``View/background(_:in:fillStyle:)-89n7j``, and passing in a | |
/// ``Material``. You can also set the value manually, using | |
/// `nil` to disable vibrant rendering, or a ``Material`` instance to | |
/// enable the vibrancy style associated with the specified material. | |
public var backgroundMaterial: Material? | |
} | |
/// A modifier that must resolve to a concrete modifier in an environment before | |
/// use. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol EnvironmentalModifier : ViewModifier where Self.Body == Never { | |
/// The type of modifier to use after being resolved. | |
associatedtype ResolvedModifier : ViewModifier | |
/// Resolve to a concrete modifier in the given `environment`. | |
func resolve(in environment: EnvironmentValues) -> Self.ResolvedModifier | |
} | |
/// A view type that compares itself against its previous value and prevents its | |
/// child updating if its new value is the same as its old value. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct EquatableView<Content> : View where Content : Equatable, Content : View { | |
public var content: Content | |
@inlinable public init(content: Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A set of key modifiers that you can add to a gesture. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct EventModifiers : OptionSet { | |
/// The raw value. | |
public let rawValue: Int | |
/// Creates a new set from a raw value. | |
/// | |
/// - Parameter rawValue: The raw value with which to create the key | |
/// modifier. | |
public init(rawValue: Int) | |
/// The Caps Lock key. | |
public static let capsLock: EventModifiers | |
/// The Shift key. | |
public static let shift: EventModifiers | |
/// The Control key. | |
public static let control: EventModifiers | |
/// The Option key. | |
public static let option: EventModifiers | |
/// The Command key. | |
public static let command: EventModifiers | |
/// Any key on the numeric keypad. | |
public static let numericPad: EventModifiers | |
/// The Function key. | |
@available(iOS, deprecated: 15.0, message: "Function modifier is reserved for system applications") | |
@available(macOS, deprecated: 12.0, message: "Function modifier is reserved for system applications") | |
@available(tvOS, deprecated: 15.0, message: "Function modifier is reserved for system applications") | |
@available(watchOS, deprecated: 8.0, message: "Function modifier is reserved for system applications") | |
public static let function: EventModifiers | |
/// All possible modifier keys. | |
public static let all: EventModifiers | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = EventModifiers | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = EventModifiers | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension EventModifiers : Sendable { | |
} | |
/// A schedule for updating a timeline view at the start of every minute. | |
/// | |
/// Do not use this type directly. Instead, use | |
/// ``TimelineSchedule/everyMinute``. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct EveryMinuteTimelineSchedule : TimelineSchedule { | |
/// The sequence of dates in an every minute schedule. | |
/// | |
/// The ``EveryMinuteTimelineSchedule/entries(from:mode:)`` method returns | |
/// a value of this type, which is a | |
/// <doc://com.apple.documentation/documentation/Swift/Sequence> | |
/// of dates, one per minute, in ascending order. A ``TimelineView`` that | |
/// you create updates its content at the moments in time corresponding to | |
/// the dates included in the sequence. | |
public struct Entries : Sequence, IteratorProtocol { | |
/// Advances to the next element and returns it, or `nil` if no next element | |
/// exists. | |
/// | |
/// Repeatedly calling this method returns, in order, all the elements of the | |
/// underlying sequence. As soon as the sequence has run out of elements, all | |
/// subsequent calls return `nil`. | |
/// | |
/// You must not call this method if any other copy of this iterator has been | |
/// advanced with a call to its `next()` method. | |
/// | |
/// The following example shows how an iterator can be used explicitly to | |
/// emulate a `for`-`in` loop. First, retrieve a sequence's iterator, and | |
/// then call the iterator's `next()` method until it returns `nil`. | |
/// | |
/// let numbers = [2, 3, 5, 7] | |
/// var numbersIterator = numbers.makeIterator() | |
/// | |
/// while let num = numbersIterator.next() { | |
/// print(num) | |
/// } | |
/// // Prints "2" | |
/// // Prints "3" | |
/// // Prints "5" | |
/// // Prints "7" | |
/// | |
/// - Returns: The next element in the underlying sequence, if a next element | |
/// exists; otherwise, `nil`. | |
public mutating func next() -> Date? | |
/// A type representing the sequence's elements. | |
public typealias Element = Date | |
/// A type that provides the sequence's iteration interface and | |
/// encapsulates its iteration state. | |
public typealias Iterator = EveryMinuteTimelineSchedule.Entries | |
} | |
/// Creates a per-minute update schedule. | |
/// | |
/// Use the ``EveryMinuteTimelineSchedule/entries(from:mode:)`` method | |
/// to get the sequence of dates. | |
@available(iOS, introduced: 15.0, deprecated: 15.0, message: "Use `.everyMinute` instead.") | |
@available(macOS, introduced: 12.0, deprecated: 12.0, message: "Use `.everyMinute` instead.") | |
@available(tvOS, introduced: 15.0, deprecated: 15.0, message: "Use `.everyMinute` instead.") | |
@available(watchOS, introduced: 8.0, deprecated: 8.0, message: "Use `.everyMinute` instead.") | |
public init() | |
/// Provides a sequence of per-minute dates starting from a given date. | |
/// | |
/// A ``TimelineView`` that you create with an every minute schedule | |
/// calls this method to ask the schedule when to update its content. | |
/// The method returns a sequence of per-minute dates in increasing | |
/// order, from earliest to latest, that represents | |
/// when the timeline view updates. | |
/// | |
/// For a `startDate` that's exactly minute-aligned, the | |
/// schedule's sequence of dates starts at that time. Otherwise, it | |
/// starts at the beginning of the specified minute. For | |
/// example, for start dates of both `10:09:32` and `10:09:00`, the first | |
/// entry in the sequence is `10:09:00`. | |
/// | |
/// - Parameters: | |
/// - startDate: The date from which the sequence begins. | |
/// - mode: The mode for the update schedule. | |
/// - Returns: A sequence of per-minute dates in ascending order. | |
public func entries(from startDate: Date, mode: TimelineScheduleMode) -> EveryMinuteTimelineSchedule.Entries | |
} | |
/// A gesture that consists of two gestures where only one of them can succeed. | |
/// | |
/// The `ExclusiveGesture` gives precedence to its first gesture. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct ExclusiveGesture<First, Second> : Gesture where First : Gesture, Second : Gesture { | |
/// The value of an exclusive gesture that indicates which of two gestures | |
/// succeeded. | |
@frozen public enum Value { | |
/// The first of two gestures succeeded. | |
case first(First.Value) | |
/// The second of two gestures succeeded. | |
case second(Second.Value) | |
} | |
/// The first of two gestures. | |
public var first: First | |
/// The second of two gestures. | |
public var second: Second | |
/// Creates a gesture from two gestures where only one of them succeeds. | |
/// | |
/// - Parameters: | |
/// - first: The first of two gestures. This gesture has precedence over | |
/// the other gesture. | |
/// - second: The second of two gestures. | |
@inlinable public init(_ first: First, _ second: Second) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ExclusiveGesture.Value : Equatable where First.Value : Equatable, Second.Value : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: ExclusiveGesture<First, Second>.Value, b: ExclusiveGesture<First, Second>.Value) -> Bool | |
} | |
/// A schedule for updating a timeline view at explicit points in time. | |
/// | |
/// Do not use this type directly. Instead, use | |
/// ``TimelineSchedule/explicit(_:)``. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct ExplicitTimelineSchedule<Entries> : TimelineSchedule where Entries : Sequence, Entries.Element == Date { | |
/// Creates a schedule composed of an explicit sequence of dates. | |
/// | |
/// Use the ``ExplicitTimelineSchedule/entries(from:mode:)`` method | |
/// to get the sequence of dates. | |
/// | |
/// - Parameter dates: The sequence of dates at which a timeline view | |
/// updates. Use a monotonically increasing sequence of dates, | |
/// and ensure that at least one is in the future. | |
@available(iOS, introduced: 15.0, deprecated: 15.0, message: "Use `.explicit(_:)` instead.") | |
@available(macOS, introduced: 12.0, deprecated: 12.0, message: "Use `.explicit(_:)` instead.") | |
@available(tvOS, introduced: 15.0, deprecated: 15.0, message: "Use `.explicit(_:)` instead.") | |
@available(watchOS, introduced: 8.0, deprecated: 8.0, message: "Use `.explicit(_:)` instead.") | |
public init(_ dates: Entries) | |
/// Provides the sequence of dates with which you initialized the schedule. | |
/// | |
/// A ``TimelineView`` that you create with a schedule calls this | |
/// ``TimelineSchedule`` method to ask the schedule when to update its | |
/// content. The explicit timeline schedule implementation | |
/// of this method returns the unmodified sequence of dates that you | |
/// provided when you created the schedule with | |
/// ``TimelineSchedule/explicit(_:)``. As a result, this particular | |
/// implementation ignores the `startDate` and `mode` parameters. | |
/// | |
/// - Parameters: | |
/// - startDate: The date from which the sequence begins. This | |
/// particular implementation of the protocol method ignores the start | |
/// date. | |
/// - mode: The mode for the update schedule. This particular | |
/// implementation of the protocol method ignores the mode. | |
/// - Returns: The sequence of dates that you provided at initialization. | |
public func entries(from startDate: Date, mode: TimelineScheduleMode) -> Entries | |
} | |
/// A property wrapper type that makes fetch requests and retrieves the results | |
/// from a Core Data store. | |
/// | |
/// The fetch request and its results use the managed object context provided by | |
/// the environment value ``EnvironmentValues/managedObjectContext``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@propertyWrapper public struct FetchRequest<Result> where Result : NSFetchRequestResult { | |
/// The fetched results of the fetch request. | |
/// | |
/// This property returns an empty array when there are no fetched results. | |
public var wrappedValue: FetchedResults<Result> { get } | |
/// The request's configurable properties. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct Configuration { | |
/// The request's sort descriptors. | |
public var nsSortDescriptors: [NSSortDescriptor] | |
/// The request's predicate. | |
public var nsPredicate: NSPredicate? | |
} | |
/// A binding to the request's mutable configuration properties | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public var projectedValue: Binding<FetchRequest<Result>.Configuration> { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension FetchRequest : DynamicProperty { | |
/// Updates the fetched results. | |
/// | |
/// SwiftUI calls this function before rendering a view's | |
/// ``View/body-swift.property`` to ensure the view has the most recent | |
/// fetched results. | |
public mutating func update() | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension FetchRequest { | |
/// Creates an instance by defining a fetch request based on the parameters. | |
/// - Parameters: | |
/// - entity: The kind of modeled object to fetch. | |
/// - sortDescriptors: An array of sort descriptors defines the sort | |
/// order of the fetched results. | |
/// - predicate: An NSPredicate defines a filter for the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(entity: NSEntityDescription, sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil) | |
/// Creates an instance from a fetch request. | |
/// - Parameters: | |
/// - fetchRequest: The request used to produce the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(fetchRequest: NSFetchRequest<Result>, animation: Animation? = nil) | |
/// Creates an instance from a fetch request. | |
/// - Parameters: | |
/// - fetchRequest: The request used to produce the fetched results. | |
/// - transaction: The transaction used for any changes to the fetched | |
/// results. | |
public init(fetchRequest: NSFetchRequest<Result>, transaction: Transaction) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension FetchRequest where Result : NSManagedObject { | |
/// Creates an instance by defining a fetch request based on the parameters. | |
/// The fetch request will automatically infer the entity using Result.entity() at fetch-time. | |
/// - Parameters: | |
/// - sortDescriptors: An array of sort descriptors defines the sort | |
/// order of the fetched results. | |
/// - predicate: An NSPredicate defines a filter for the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension FetchRequest where Result : NSManagedObject { | |
/// Creates an instance by defining a fetch request based on the parameters. | |
/// | |
/// The fetch request will automatically infer the entity using Result.entity() at fetch-time. | |
/// - Parameters: | |
/// - sortDescriptors: An array of sort descriptors defines the sort | |
/// order of the fetched results. | |
/// - predicate: An NSPredicate defines a filter for the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(sortDescriptors: [SortDescriptor<Result>], predicate: NSPredicate? = nil, animation: Animation? = nil) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension FetchRequest.Configuration where Result : NSManagedObject { | |
public var sortDescriptors: [SortDescriptor<Result>] | |
} | |
/// The FetchedResults collection type represents the results of performing a | |
/// fetch request. Internally, it may use strategies such as batching and | |
/// transparent futures to minimize memory use and I/O. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct FetchedResults<Result> : RandomAccessCollection where Result : NSFetchRequestResult { | |
/// The request's sort descriptors. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public var nsSortDescriptors: [NSSortDescriptor] { get nonmutating set } | |
/// The request's predicate. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public var nsPredicate: NSPredicate? { get nonmutating set } | |
/// The position of the first element in a nonempty collection. | |
/// | |
/// If the collection is empty, `startIndex` is equal to `endIndex`. | |
public var startIndex: Int { get } | |
/// The collection's "past the end" position---that is, the position one | |
/// greater than the last valid subscript argument. | |
/// | |
/// When you need a range that includes the last element of a collection, use | |
/// the half-open range operator (`..<`) with `endIndex`. The `..<` operator | |
/// creates a range that doesn't include the upper bound, so it's always | |
/// safe to use with `endIndex`. For example: | |
/// | |
/// let numbers = [10, 20, 30, 40, 50] | |
/// if let index = numbers.firstIndex(of: 30) { | |
/// print(numbers[index ..< numbers.endIndex]) | |
/// } | |
/// // Prints "[30, 40, 50]" | |
/// | |
/// If the collection is empty, `endIndex` is equal to `startIndex`. | |
public var endIndex: Int { get } | |
/// Accesses the element at the specified position. | |
/// | |
/// The following example accesses an element of an array through its | |
/// subscript to print its value: | |
/// | |
/// var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] | |
/// print(streets[1]) | |
/// // Prints "Bryant" | |
/// | |
/// You can subscript a collection with any valid index other than the | |
/// collection's end index. The end index refers to the position one past | |
/// the last element of a collection, so it doesn't correspond with an | |
/// element. | |
/// | |
/// - Parameter position: The position of the element to access. `position` | |
/// must be a valid index of the collection that is not equal to the | |
/// `endIndex` property. | |
/// | |
/// - Complexity: O(1) | |
public subscript(position: Int) -> Result { get } | |
/// A type representing the sequence's elements. | |
public typealias Element = Result | |
/// A type that represents a position in the collection. | |
/// | |
/// Valid indices consist of the position of every element and a | |
/// "past the end" position that's not valid for use as a subscript | |
/// argument. | |
public typealias Index = Int | |
/// A type that represents the indices that are valid for subscripting the | |
/// collection, in ascending order. | |
public typealias Indices = Range<Int> | |
/// A type that provides the collection's iteration interface and | |
/// encapsulates its iteration state. | |
/// | |
/// By default, a collection conforms to the `Sequence` protocol by | |
/// supplying `IndexingIterator` as its associated `Iterator` | |
/// type. | |
public typealias Iterator = IndexingIterator<FetchedResults<Result>> | |
/// A sequence that represents a contiguous subrange of the collection's | |
/// elements. | |
/// | |
/// This associated type appears as a requirement in the `Sequence` | |
/// protocol, but it is restated here with stricter constraints. In a | |
/// collection, the subsequence should also conform to `Collection`. | |
public typealias SubSequence = Slice<FetchedResults<Result>> | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension FetchedResults where Result : NSManagedObject { | |
public var sortDescriptors: [SortDescriptor<Result>] { get nonmutating set } | |
} | |
/// A document model definition used to serialize documents to and from file | |
/// contents. | |
/// | |
/// Conformance to `FileDocument` requires value semantics and thread-safety. | |
/// Serialization and deserialization occur on a background thread. | |
/// | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public protocol FileDocument { | |
/// The types the document is able to open. | |
static var readableContentTypes: [UTType] { get } | |
/// The types the document is able to save or export to. | |
/// | |
/// If you don't implement this property, the protocol returns | |
/// the value in ``readableContentTypes`` by default. | |
static var writableContentTypes: [UTType] { get } | |
/// Creates a file document from the given configuration. | |
init(configuration: Self.ReadConfiguration) throws | |
/// The configuration for reading document contents. | |
typealias ReadConfiguration = FileDocumentReadConfiguration | |
/// Serializes the document to file contents for a specified configuration. | |
/// | |
/// - Parameter configuration: The configuration for the current document | |
/// contents. | |
/// | |
/// - Returns: The destination to serialize the document contents to. The | |
/// value can be a newly created | |
/// <doc://com.apple.documentation/documentation/Foundation/FileWrapper> | |
/// or an updated file wrapper of the one provided in `configuration`. | |
func fileWrapper(configuration: Self.WriteConfiguration) throws -> FileWrapper | |
/// The configuration for serializing document contents. | |
typealias WriteConfiguration = FileDocumentWriteConfiguration | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension FileDocument { | |
/// The types the document is able to save or export to. | |
/// | |
/// If you don't implement this property, the protocol returns | |
/// the value in ``readableContentTypes`` by default. | |
public static var writableContentTypes: [UTType] { get } | |
} | |
/// The properties of an open file document. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct FileDocumentConfiguration<Document> where Document : FileDocument { | |
/// The current document model. | |
/// | |
/// Setting a new value marks the document as having changes for later | |
/// saving and registers an undo action to restore the model to its | |
/// previous value. | |
/// | |
/// If ``isEditable`` is `false`, setting a new value won't have an effect | |
/// and the document is in viewing mode. | |
public var document: Document { get nonmutating set } | |
public var $document: Binding<Document> { get } | |
/// The URL of the open file document. | |
public var fileURL: URL? | |
/// Whether the document is editable. | |
/// | |
/// This value is `false` if the document is in viewing mode, or if the | |
/// file is not writable. | |
public var isEditable: Bool | |
} | |
/// The configuration for reading file contents. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct FileDocumentReadConfiguration { | |
/// The expected uniform type of the file contents. | |
public let contentType: UTType | |
/// The file wrapper containing the document content. | |
public let file: FileWrapper | |
} | |
/// The configuration for serializing file contents. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct FileDocumentWriteConfiguration { | |
/// The expected uniform type of the file contents. | |
public let contentType: UTType | |
/// The file wrapper containing the current document content. | |
/// `nil` if the document is unsaved. | |
public let existingFile: FileWrapper? | |
} | |
/// A style for rasterizing vector shapes. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct FillStyle : Equatable { | |
/// A Boolean value that indicates whether to use the even-odd rule when | |
/// rendering a shape. | |
/// | |
/// When `isOEFilled` is `false`, the style uses the non-zero winding number | |
/// rule. | |
public var isEOFilled: Bool | |
/// A Boolean value that indicates whether to apply antialiasing to the | |
/// edges of a shape. | |
public var isAntialiased: Bool | |
/// Creates a new fill style with the specified settings. | |
/// | |
/// - Parameters: | |
/// - eoFill: A Boolean value that indicates whether to use the even-odd | |
/// rule for rendering a shape. Pass `false` to use the non-zero winding | |
/// number rule instead. | |
/// - antialiased: A Boolean value that indicates whether to use | |
/// antialiasing when rendering the edges of a shape. | |
@inlinable public init(eoFill: Bool = false, antialiased: Bool = true) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: FillStyle, b: FillStyle) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension FillStyle : Sendable { | |
} | |
/// A property wrapper type that can read and write a value that SwiftUI updates | |
/// as the placement of focus within the scene changes. | |
/// | |
/// Use this property wrapper in conjunction with ``View/focused(_:equals:)`` | |
/// and ``View/focused(_:)`` to | |
/// describe views whose appearance and contents relate to the location of | |
/// focus in the scene. When focus enters the modified view, the wrapped value | |
/// of this property updates to match a given prototype value. Similarly, when | |
/// focus leaves, the wrapped value of this property resets to `nil` | |
/// or `false`. Setting the property's value programmatically has the reverse | |
/// effect, causing focus to move to the view associated with the | |
/// updated value. | |
/// | |
/// In the following example of a simple login screen, when the user presses the | |
/// Sign In button and one of the fields is still empty, focus moves to that | |
/// field. Otherwise, the sign-in process proceeds. | |
/// | |
/// struct LoginForm { | |
/// enum Field: Hashable { | |
/// case username | |
/// case password | |
/// } | |
/// | |
/// @State private var username = "" | |
/// @State private var password = "" | |
/// @FocusState private var focusedField: Field? | |
/// | |
/// var body: some View { | |
/// Form { | |
/// TextField("Username", text: $username) | |
/// .focused($focusedField, equals: .username) | |
/// | |
/// SecureField("Password", text: $password) | |
/// .focused($focusedField, equals: .password) | |
/// | |
/// Button("Sign In") { | |
/// if username.isEmpty { | |
/// focusedField = .username | |
/// } else if password.isEmpty { | |
/// focusedField = .password | |
/// } else { | |
/// handleLogin(username, password) | |
/// } | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
/// To allow for cases where focus is completely absent from a view tree, the | |
/// wrapped value must be either an optional or a Boolean. Set the focus binding | |
/// to `false` or `nil` as appropriate to remove focus from all bound fields. | |
/// You can also use this to remove focus from a ``TextField`` and thereby | |
/// dismiss the keyboard. | |
/// | |
/// ### Avoid Ambiguous Focus Bindings | |
/// | |
/// The same view can have multiple focus bindings. In the following example, | |
/// setting `focusedField` to either `name` or `fullName` causes the field | |
/// to receive focus: | |
/// | |
/// struct ContentView: View { | |
/// enum Field: Hashable { | |
/// case name | |
/// case fullName | |
/// } | |
/// @FocusState private var focusedField: Field? | |
/// | |
/// var body: some View { | |
/// TextField("Full Name", ...) | |
/// .focused($focusedField, equals: .name) | |
/// .focused($focusedField, equals: .fullName) | |
/// } | |
/// } | |
/// | |
/// On the other hand, binding the same value to two views is ambiguous. In | |
/// the following example, two separate fields bind focus to the `name` value: | |
/// | |
/// struct ContentView: View { | |
/// enum Field: Hashable { | |
/// case name | |
/// case fullName | |
/// } | |
/// @FocusState private var focusedField: Field? | |
/// | |
/// var body: some View { | |
/// TextField("Name", ...) | |
/// .focused($focusedField, equals: .name) | |
/// TextField("Full Name", ...) | |
/// .focused($focusedField, equals: .name) // incorrect re-use of .name | |
/// } | |
/// } | |
/// | |
/// If the user moves focus to either field, the `focusedField` binding updates | |
/// to `name`. However, if the app programmatically sets the value to `name`, | |
/// SwiftUI chooses the first candidate, which in this case is the "Name" | |
/// field. SwiftUI also emits a runtime warning in this case, since the repeated | |
/// binding is likely a programmer error. | |
/// | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
@frozen @propertyWrapper public struct FocusState<Value> : DynamicProperty where Value : Hashable { | |
/// A property wrapper type that can read and write a value that indicates | |
/// the current focus location. | |
@propertyWrapper public struct Binding { | |
/// The underlying value referenced by the bound property. | |
public var wrappedValue: Value { get nonmutating set } | |
/// A projection of the binding value that returns a binding. | |
/// | |
/// Use the projected value to pass a binding value down a view | |
/// hierarchy. | |
public var projectedValue: FocusState<Value>.Binding { get } | |
} | |
/// The current state value, taking into account whatever bindings might be | |
/// in effect due to the current location of focus. | |
/// | |
/// When focus is not in any view that is bound to this state, the wrapped | |
/// value will be `nil` (for optional-typed state) or `false` (for `Bool`- | |
/// typed state). | |
public var wrappedValue: Value { get nonmutating set } | |
/// A projection of the focus state value that returns a binding. | |
/// | |
/// When focus is outside any view that is bound to this state, the wrapped | |
/// value is `nil` for optional-typed state or `false` for Boolean state. | |
/// | |
/// In the following example of a simple navigation sidebar, when the user | |
/// presses the Filter Sidebar Contents button, focus moves to the sidebar's | |
/// filter text field. Conversely, if the user moves focus to the sidebar's | |
/// filter manually, then the value of `isFiltering` automatically | |
/// becomes `true`, and the sidebar view updates. | |
/// | |
/// struct Sidebar: View { | |
/// @State private var filterText = "" | |
/// @FocusState private var isFiltering: Bool | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// Button("Filter Sidebar Contents") { | |
/// isFiltering = true | |
/// } | |
/// | |
/// TextField("Filter", text: $filterText) | |
/// .focused($isFiltering) | |
/// } | |
/// } | |
/// } | |
public var projectedValue: FocusState<Value>.Binding { get } | |
/// Creates a focus state that binds to a Boolean. | |
public init() where Value == Bool | |
/// Creates a focus state that binds to an optional type. | |
public init<T>() where Value == T?, T : Hashable | |
} | |
/// A convenience property wrapper for observing and automatically unwrapping | |
/// state bindings from the focused view or one of its ancestors. | |
/// | |
/// If multiple views publish bindings using the same key, the wrapped property | |
/// will reflect the value of the binding from the view closest to focus. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@propertyWrapper public struct FocusedBinding<Value> : DynamicProperty { | |
/// A new property wrapper for the given key path. | |
/// | |
/// The value of the property wrapper is updated dynamically as focus | |
/// changes and different published bindings go in and out of scope. | |
/// | |
/// - Parameter keyPath: The key path for the focus value to read. | |
public init(_ keyPath: KeyPath<FocusedValues, Binding<Value>?>) | |
/// The unwrapped value for the focus key given the current scope and state | |
/// of the focused view hierarchy. | |
@inlinable public var wrappedValue: Value? { get nonmutating set } | |
/// A binding to the optional value. | |
/// | |
/// The unwrapped value is `nil` when no focused view hierarchy has | |
/// published a corresponding binding. | |
public var projectedValue: Binding<Value?> { get } | |
} | |
/// A property wrapper for observing values from the focused view or one of its | |
/// ancestors. | |
/// | |
/// If multiple views publish values using the same key, the wrapped property | |
/// will reflect the value from the view closest to focus. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@propertyWrapper public struct FocusedValue<Value> : DynamicProperty { | |
/// A new property wrapper for the given key path. | |
/// | |
/// The value of the property wrapper is updated dynamically as focus | |
/// changes and different published values go in and out of scope. | |
/// | |
/// - Parameter keyPath: The key path for the focus value to read. | |
public init(_ keyPath: KeyPath<FocusedValues, Value?>) | |
/// The value for the focus key given the current scope and state of the | |
/// focused view hierarchy. | |
/// | |
/// Returns `nil` when nothing in the focused view hierarchy exports a | |
/// value. | |
@inlinable public var wrappedValue: Value? { get } | |
} | |
/// A protocol for identifier types used when publishing and observing focused | |
/// values. | |
/// | |
/// Unlike `EnvironmentKey`, `FocusedValuesHostKey` has no default value | |
/// requirement, because the default value for a key is always `nil`. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol FocusedValueKey { | |
associatedtype Value | |
} | |
/// A collection of state exported by the focused view and its ancestors. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct FocusedValues { | |
/// Reads and writes values associated with a given focused value key. | |
public subscript<Key>(key: Key.Type) -> Key.Value? where Key : FocusedValueKey | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension FocusedValues : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (lhs: FocusedValues, rhs: FocusedValues) -> Bool | |
} | |
/// An environment-dependent font. | |
/// | |
/// The system resolves a font's value at the time it uses the font in a given | |
/// environment because ``Font`` is a late-binding token. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Font : Hashable { | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (lhs: Font, rhs: Font) -> Bool | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font { | |
/// A font with the large title text style. | |
public static let largeTitle: Font | |
/// A font with the title text style. | |
public static let title: Font | |
/// Create a font for second level hierarchical headings. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public static let title2: Font | |
/// Create a font for third level hierarchical headings. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public static let title3: Font | |
/// A font with the headline text style. | |
public static let headline: Font | |
/// A font with the subheadline text style. | |
public static let subheadline: Font | |
/// A font with the body text style. | |
public static let body: Font | |
/// A font with the callout text style. | |
public static let callout: Font | |
/// A font with the footnote text style. | |
public static let footnote: Font | |
/// A font with the caption text style. | |
public static let caption: Font | |
/// Create a font with the alternate caption text style. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public static let caption2: Font | |
/// Gets a system font with the given style and design. | |
public static func system(_ style: Font.TextStyle, design: Font.Design = .default) -> Font | |
/// A dynamic text style to use for fonts. | |
public enum TextStyle : CaseIterable { | |
/// The font style for large titles. | |
case largeTitle | |
/// The font used for first level hierarchical headings. | |
case title | |
/// The font used for second level hierarchical headings. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
case title2 | |
/// The font used for third level hierarchical headings. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
case title3 | |
/// The font used for headings. | |
case headline | |
/// The font used for subheadings. | |
case subheadline | |
/// The font used for body text. | |
case body | |
/// The font used for callouts. | |
case callout | |
/// The font used in footnotes. | |
case footnote | |
/// The font used for standard captions. | |
case caption | |
/// The font used for alternate captions. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
case caption2 | |
/// A collection of all values of this type. | |
public static var allCases: [Font.TextStyle] | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Font.TextStyle, b: Font.TextStyle) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [Font.TextStyle] | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font { | |
/// Adds italics to the font. | |
public func italic() -> Font | |
/// Adjusts the font to enable all small capitals. | |
/// | |
/// See ``Font/lowercaseSmallCaps()`` and ``Font/uppercaseSmallCaps()`` for | |
/// more details. | |
public func smallCaps() -> Font | |
/// Adjusts the font to enable lowercase small capitals. | |
/// | |
/// This function turns lowercase characters into small capitals for the | |
/// font. It is generally used for display lines set in large and small | |
/// caps, such as titles. It may include forms related to small capitals, | |
/// such as old-style figures. | |
public func lowercaseSmallCaps() -> Font | |
/// Adjusts the font to enable uppercase small capitals. | |
/// | |
/// This feature turns capital characters into small capitals. It is | |
/// generally used for words which would otherwise be set in all caps, such | |
/// as acronyms, but which are desired in small-cap form to avoid disrupting | |
/// the flow of text. | |
public func uppercaseSmallCaps() -> Font | |
/// Adjusts the font to use monospace digits. | |
public func monospacedDigit() -> Font | |
/// Sets the weight of the font. | |
public func weight(_ weight: Font.Weight) -> Font | |
/// Adds bold styling to the font. | |
public func bold() -> Font | |
/// Switches the font to a monospaced version of the same family | |
/// as the base font or a default monospaced font | |
/// if no suitable font face in the same family is found. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public func monospaced() -> Font | |
/// Create a version of `self` that uses leading (line spacing) adjustment. | |
/// | |
/// The availability of leading adjustments depends on font. | |
/// | |
/// For example, `Font.body.tightLeading()` will return a `Font` in `body` | |
/// text style with tight line spacing. This modifier may return the | |
/// original `Font` unchanged for some fonts. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public func leading(_ leading: Font.Leading) -> Font | |
/// A weight to use for fonts. | |
@frozen public struct Weight : Hashable { | |
public static let ultraLight: Font.Weight | |
public static let thin: Font.Weight | |
public static let light: Font.Weight | |
public static let regular: Font.Weight | |
public static let medium: Font.Weight | |
public static let semibold: Font.Weight | |
public static let bold: Font.Weight | |
public static let heavy: Font.Weight | |
public static let black: Font.Weight | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Font.Weight, b: Font.Weight) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public enum Leading { | |
case standard | |
case tight | |
case loose | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Font.Leading, b: Font.Leading) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font { | |
/// Specifies a system font to use, along with the style, weight, and any | |
/// design parameters you want applied to the text. | |
/// | |
/// Use this function to create a system font by specifying the size and | |
/// weight, and a type design together. The following styles the system font | |
/// as 17 point, ``Font/Weight/semibold`` text: | |
/// | |
/// Text("Hello").font(.system(size: 17, weight: .semibold)) | |
/// | |
/// While the following styles the text as 17 point ``Font/Weight/bold``, | |
/// and applies a `serif` ``Font/Design`` to the system font: | |
/// | |
/// Text("Hello").font(.system(size: 17, weight: .bold, design: .serif)) | |
/// | |
/// If you want to use the default ``Font/Weight`` | |
/// (``Font/Weight/regular``), you don't need to specify the `weight` in the | |
/// method. The following example styles the text as 17 point | |
/// ``Font/Weight/regular``, and uses a ``Font/Design/rounded`` system font: | |
/// | |
/// Text("Hello").font(.system(size: 17, design: .rounded)) | |
public static func system(size: CGFloat, weight: Font.Weight = .regular, design: Font.Design = .default) -> Font | |
/// A design to use for fonts. | |
public enum Design : Hashable { | |
case `default` | |
@available(watchOS 7.0, *) | |
case serif | |
case rounded | |
@available(watchOS 7.0, *) | |
case monospaced | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Font.Design, b: Font.Design) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font { | |
/// Create a custom font with the given `name` and `size` that scales with | |
/// the body text style. | |
public static func custom(_ name: String, size: CGFloat) -> Font | |
/// Create a custom font with the given `name` and `size` that scales | |
/// relative to the given `textStyle`. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public static func custom(_ name: String, size: CGFloat, relativeTo textStyle: Font.TextStyle) -> Font | |
/// Create a custom font with the given `name` and a fixed `size` that does | |
/// not scale with Dynamic Type. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public static func custom(_ name: String, fixedSize: CGFloat) -> Font | |
/// Creates a custom font from a platform font instance. | |
/// | |
/// Initializing ``Font`` with platform font instance | |
/// (<doc://com.apple.documentation/documentation/CoreText/CTFont-q6r>) can bridge SwiftUI | |
/// ``Font`` with <doc://com.apple.documentation/documentation/AppKit/NSFont> or | |
/// <doc://com.apple.documentation/documentation/UIKit/UIFont>, both of which are | |
/// toll-free bridged to | |
/// <doc://com.apple.documentation/documentation/CoreText/CTFont-q6r>. For example: | |
/// | |
/// // Use native Core Text API to create desired ctFont. | |
/// let ctFont = CTFontCreateUIFontForLanguage(.system, 12, nil)! | |
/// | |
/// // Create SwiftUI Text with the CTFont instance. | |
/// let text = Text("Hello").font(Font(ctFont)) | |
public init(_ font: CTFont) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font.TextStyle : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font.TextStyle : Hashable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Font.Weight : Sendable { | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Font.Leading : Equatable { | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Font.Leading : Hashable { | |
} | |
/// A structure that computes views on demand from an underlying collection of | |
/// identified data. | |
/// | |
/// Use `ForEach` to provide views based on a | |
/// <doc://com.apple.documentation/documentation/Swift/RandomAccessCollection> | |
/// of some data type. Either the collection's elements must conform to | |
/// <doc://com.apple.documentation/documentation/Swift/Identifiable> or you | |
/// need to provide an `id` parameter to the `ForEach` initializer. | |
/// | |
/// The following example creates a `NamedFont` type that conforms to | |
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>, and an | |
/// array of this type called `namedFonts`. A `ForEach` instance iterates | |
/// over the array, producing new ``Text`` instances that display examples | |
/// of each SwiftUI ``Font`` style provided in the array. | |
/// | |
/// private struct NamedFont: Identifiable { | |
/// let name: String | |
/// let font: Font | |
/// var id: String { name } | |
/// } | |
/// | |
/// private let namedFonts: [NamedFont] = [ | |
/// NamedFont(name: "Large Title", font: .largeTitle), | |
/// NamedFont(name: "Title", font: .title), | |
/// NamedFont(name: "Headline", font: .headline), | |
/// NamedFont(name: "Body", font: .body), | |
/// NamedFont(name: "Caption", font: .caption) | |
/// ] | |
/// | |
/// var body: some View { | |
/// ForEach(namedFonts) { namedFont in | |
/// Text(namedFont.name) | |
/// .font(namedFont.font) | |
/// } | |
/// } | |
/// | |
/// ![A vertically arranged stack of labels showing various standard fonts, | |
/// such as Large Title and Headline.](SwiftUI-ForEach-fonts.png) | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct ForEach<Data, ID, Content> where Data : RandomAccessCollection, ID : Hashable { | |
/// The collection of underlying identified data that SwiftUI uses to create | |
/// views dynamically. | |
public var data: Data | |
/// A function to create content on demand using the underlying data. | |
public var content: (Data.Element) -> Content | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForEach : DynamicViewContent where Content : View { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ForEach : AccessibilityRotorContent where Content : AccessibilityRotorContent { | |
/// The internal content of this `AccessibilityRotorContent`. | |
public var body: Never { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ForEach where ID == Data.Element.ID, Content : AccessibilityRotorContent, Data.Element : Identifiable { | |
/// Creates an instance that generates Rotor content by combining, in order, | |
/// individual Rotor content for each element in the data given to this | |
/// `ForEach`. | |
/// | |
/// It's important that the `id` of a data element doesn't change unless you | |
/// replace the data element with a new data element that has a new | |
/// identity. | |
/// | |
/// - Parameters: | |
/// - data: The identified data that the ``ForEach`` instance uses to | |
/// create views dynamically. | |
/// - content: The result builder that generates Rotor content for each | |
/// data element. | |
public init(_ data: Data, @AccessibilityRotorContentBuilder content: @escaping (Data.Element) -> Content) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ForEach where Content : AccessibilityRotorContent { | |
/// Creates an instance that generates Rotor content by combining, in order, | |
/// individual Rotor content for each element in the data given to this | |
/// `ForEach`. | |
/// | |
/// It's important that the `id` of a data element doesn't change, unless | |
/// SwiftUI considers the data element to have been replaced with a new data | |
/// element that has a new identity. | |
/// | |
/// - Parameters: | |
/// - data: The data that the ``ForEach`` instance uses to create views | |
/// dynamically. | |
/// - id: The key path to the provided data's identifier. | |
/// - content: The result builder that generates Rotor content for each | |
/// data element. | |
public init(_ data: Data, id: KeyPath<Data.Element, ID>, @AccessibilityRotorContentBuilder content: @escaping (Data.Element) -> Content) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForEach : View where Content : View { | |
/// The type for the internal content of this `AccessibilityRotorContent`. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForEach where ID == Data.Element.ID, Content : View, Data.Element : Identifiable { | |
/// Creates an instance that uniquely identifies and creates views across | |
/// updates based on the identity of the underlying data. | |
/// | |
/// It's important that the `id` of a data element doesn't change unless you | |
/// replace the data element with a new data element that has a new | |
/// identity. If the `id` of a data element changes, the content view | |
/// generated from that data element loses any current state and animations. | |
/// | |
/// - Parameters: | |
/// - data: The identified data that the ``ForEach`` instance uses to | |
/// create views dynamically. | |
/// - content: The view builder that creates views dynamically. | |
public init(_ data: Data, @ViewBuilder content: @escaping (Data.Element) -> Content) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForEach where Content : View { | |
/// Creates an instance that uniquely identifies and creates views across | |
/// updates based on the provided key path to the underlying data's | |
/// identifier. | |
/// | |
/// It's important that the `id` of a data element doesn't change, unless | |
/// SwiftUI considers the data element to have been replaced with a new data | |
/// element that has a new identity. If the `id` of a data element changes, | |
/// then the content view generated from that data element will lose any | |
/// current state and animations. | |
/// | |
/// - Parameters: | |
/// - data: The data that the ``ForEach`` instance uses to create views | |
/// dynamically. | |
/// - id: The key path to the provided data's identifier. | |
/// - content: The view builder that creates views dynamically. | |
public init(_ data: Data, id: KeyPath<Data.Element, ID>, @ViewBuilder content: @escaping (Data.Element) -> Content) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForEach where Content : View { | |
/// Creates an instance that uniquely identifies and creates views across | |
/// updates based on the identity of the underlying data. | |
/// | |
/// It's important that the `id` of a data element doesn't change unless you | |
/// replace the data element with a new data element that has a new | |
/// identity. If the `id` of a data element changes, the content view | |
/// generated from that data element loses any current state and animations. | |
/// | |
/// - Parameters: | |
/// - data: The identified data that the ``ForEach`` instance uses to | |
/// create views dynamically. | |
/// - content: The view builder that creates views dynamically. | |
public init<C>(_ data: Binding<C>, @ViewBuilder content: @escaping (Binding<C.Element>) -> Content) where Data == LazyMapSequence<C.Indices, (C.Index, ID)>, ID == C.Element.ID, C : MutableCollection, C : RandomAccessCollection, C.Element : Identifiable, C.Index : Hashable | |
/// Creates an instance that uniquely identifies and creates views across | |
/// updates based on the identity of the underlying data. | |
/// | |
/// It's important that the `id` of a data element doesn't change unless you | |
/// replace the data element with a new data element that has a new | |
/// identity. If the `id` of a data element changes, the content view | |
/// generated from that data element loses any current state and animations. | |
/// | |
/// - Parameters: | |
/// - data: The identified data that the ``ForEach`` instance uses to | |
/// create views dynamically. | |
/// - content: The view builder that creates views dynamically. | |
public init<C>(_ data: Binding<C>, id: KeyPath<C.Element, ID>, @ViewBuilder content: @escaping (Binding<C.Element>) -> Content) where Data == LazyMapSequence<C.Indices, (C.Index, ID)>, C : MutableCollection, C : RandomAccessCollection, C.Index : Hashable | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForEach where Data == Range<Int>, ID == Int, Content : View { | |
/// Creates an instance that computes views on demand over a given constant | |
/// range. | |
/// | |
/// The instance only reads the initial value of the provided `data` and | |
/// doesn't need to identify views across updates. To compute views on | |
/// demand over a dynamic range, use ``ForEach/init(_:id:content:)``. | |
/// | |
/// - Parameters: | |
/// - data: A constant range. | |
/// - content: The view builder that creates views dynamically. | |
public init(_ data: Range<Int>, @ViewBuilder content: @escaping (Int) -> Content) | |
} | |
/// The foreground style in the current context. | |
/// | |
/// Do not use this type directly. Instead, use ``ShapeStyle/foreground``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct ForegroundStyle : ShapeStyle { | |
/// Creates a foreground style instance. | |
@inlinable public init() | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ForegroundStyle : Sendable { | |
} | |
/// A container for grouping controls used for data entry, such as in settings | |
/// or inspectors. | |
/// | |
/// SwiftUI applies platform-appropriate styling to views contained inside a | |
/// form, to group them together. Form-specific styling applies to | |
/// things like buttons, toggles, labels, lists, and more. Keep in mind that | |
/// these stylings may be platform-specific. For example, forms apppear as | |
/// grouped lists on iOS, and as aligned vertical stacks on macOS. | |
/// | |
/// The following example shows a simple data entry form on iOS, grouped into | |
/// two sections. The supporting types (`NotifyMeAboutType` and | |
/// `ProfileImageSize`) and state variables (`notifyMeAbout`, `profileImageSize`, | |
/// `playNotificationSounds`, and `sendReadReceipts`) are omitted for | |
/// simplicity. | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// Form { | |
/// Section(header: Text("Notifications")) { | |
/// Picker("Notify Me About", selection: $notifyMeAbout) { | |
/// Text("Direct Messages").tag(NotifyMeAboutType.directMessages) | |
/// Text("Mentions").tag(NotifyMeAboutType.mentions) | |
/// Text("Anything").tag(NotifyMeAboutType.anything) | |
/// } | |
/// Toggle("Play notification sounds", isOn: $playNotificationSounds) | |
/// Toggle("Send read receipts", isOn: $sendReadReceipts) | |
/// } | |
/// Section(header: Text("User Profiles")) { | |
/// Picker("Profile Image Size", selection: $profileImageSize) { | |
/// Text("Large").tag(ProfileImageSize.large) | |
/// Text("Medium").tag(ProfileImageSize.medium) | |
/// Text("Small").tag(ProfileImageSize.small) | |
/// } | |
/// Button("Clear Image Cache") {} | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
/// | |
/// ![A form on iOS, presented as a grouped list with two sections. The | |
/// first section is labeled Notifications and contains a navigation link with | |
/// the label Notify Me About and the current value Direct Messages. The section | |
/// also contains two toggles, Play Notification Sounds and Send Read Receipts, | |
/// the first of which is set to the on position. A second section named User | |
/// Profiles has a navigation link labeled Profile Image Size and the value | |
/// Medium, followed by a button labeled Clear Image | |
/// Cache.](SwiftUI-Form-iOS.png) | |
/// | |
/// On macOS, a similar form renders as a vertical stack. To adhere to macOS | |
/// platform conventions, this version doesn't use sections, and uses colons at | |
/// the end of its labels. It also sets the picker to use | |
/// the ``PickerStyle/inline`` style, which produces radio buttons on macOS. | |
/// | |
/// var body: some View { | |
/// Spacer() | |
/// HStack { | |
/// Spacer() | |
/// Form { | |
/// Picker("Notify Me About:", selection: $notifyMeAbout) { | |
/// Text("Direct Messages").tag(NotifyMeAboutType.directMessages) | |
/// Text("Mentions").tag(NotifyMeAboutType.mentions) | |
/// Text("Anything").tag(NotifyMeAboutType.anything) | |
/// } | |
/// Toggle("Play notification sounds", isOn: $playNotificationSounds) | |
/// Toggle("Send read receipts", isOn: $sendReadReceipts) | |
/// | |
/// Picker("Profile Image Size:", selection: $profileImageSize) { | |
/// Text("Large").tag(ProfileImageSize.large) | |
/// Text("Medium").tag(ProfileImageSize.medium) | |
/// Text("Small").tag(ProfileImageSize.small) | |
/// } | |
/// .pickerStyle(.inline) | |
/// | |
/// Button("Clear Image Cache") {} | |
/// } | |
/// Spacer() | |
/// } | |
/// Spacer() | |
/// } | |
/// | |
/// ![A form on iOS, presented as a vertical stack of views. At top, it shows | |
/// a pop-up menu with the label label Notify Me about and the current value | |
/// Direct Messages. Below this are two checkboxes, labeled Play Notification | |
/// Sounds and Send Read Receipts, the first of which is set on. Below this | |
/// is the label Profile Image Size with three radio buttons -- Large, Medium, | |
/// and Small -- with Medium currently selected. At the bottom of the form, | |
/// there is a button titled Clear Image Cache.](SwiftUI-Form-macOS.png) | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct Form<Content> : View where Content : View { | |
/// Creates a form with the provided content. | |
/// - Parameter content: A ``SwiftUI/ViewBuilder`` that provides the content for the | |
/// form. | |
public init(@ViewBuilder content: () -> Content) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
/// An effect that changes the visual appearance of a view, largely without | |
/// changing its ancestors or descendants. | |
/// | |
/// The only change the effect makes to the view's ancestors and descendants is | |
/// to change the coordinate transform to and from them. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol GeometryEffect : Animatable, ViewModifier where Self.Body == Never { | |
/// Returns the current value of the effect. | |
func effectValue(size: CGSize) -> ProjectionTransform | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension GeometryEffect { | |
/// Returns an effect that produces the same geometry transform as this | |
/// effect, but only applies the transform while rendering its view. | |
/// | |
/// Use this method to disable layout changes during transitions. The view | |
/// ignores the transform returned by this method while the view is | |
/// performing its layout calculations. | |
@inlinable public func ignoredByLayout() -> _IgnoredByLayoutEffect<Self> | |
} | |
/// A proxy for access to the size and coordinate space (for anchor resolution) | |
/// of the container view. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct GeometryProxy { | |
/// The size of the container view. | |
public var size: CGSize { get } | |
/// Resolves the value of `anchor` to the container view. | |
public subscript<T>(anchor: Anchor<T>) -> T { get } | |
/// The safe area inset of the container view. | |
public var safeAreaInsets: EdgeInsets { get } | |
/// Returns the container view's bounds rectangle, converted to a defined | |
/// coordinate space. | |
public func frame(in coordinateSpace: CoordinateSpace) -> CGRect | |
} | |
/// A container view that defines its content as a function of its own size and | |
/// coordinate space. | |
/// | |
/// This view returns a flexible preferred size to its parent layout. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct GeometryReader<Content> : View where Content : View { | |
public var content: (GeometryProxy) -> Content | |
@inlinable public init(@ViewBuilder content: @escaping (GeometryProxy) -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// An instance that matches a sequence of events to a gesture, and returns a | |
/// stream of values for each of its states. | |
/// | |
/// Create custom gestures by declaring types that conform to the `Gesture` | |
/// protocol. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol Gesture { | |
/// The type representing the gesture's value. | |
associatedtype Value | |
/// The type of gesture representing the body of `Self`. | |
associatedtype Body : Gesture | |
/// The content and behavior of the gesture. | |
var body: Self.Body { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture { | |
/// Sequences a gesture with another one to create a new gesture, which | |
/// results in the second gesture only receiving events after the first | |
/// gesture succeeds. | |
/// | |
/// - Parameter other: A gesture you want to combine with another gesture to | |
/// create a new, sequenced gesture. | |
/// | |
/// - Returns: A gesture that's a sequence of two gestures. | |
@inlinable public func sequenced<Other>(before other: Other) -> SequenceGesture<Self, Other> where Other : Gesture | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture { | |
/// Combines a gesture with another gesture to create a new gesture that | |
/// recognizes both gestures at the same time. | |
/// | |
/// - Parameter other: A gesture that you want to combine with your gesture | |
/// to create a new, combined gesture. | |
/// | |
/// - Returns: A gesture with two simultaneous gestures. | |
@inlinable public func simultaneously<Other>(with other: Other) -> SimultaneousGesture<Self, Other> where Other : Gesture | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture { | |
/// Adds an action to perform when the gesture ends. | |
/// | |
/// - Parameter action: The action to perform when this gesture ends. The | |
/// `action` closure's parameter contains the final value of the gesture. | |
/// | |
/// - Returns: A gesture that triggers `action` when the gesture ends. | |
public func onEnded(_ action: @escaping (Self.Value) -> Void) -> _EndedGesture<Self> | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture where Self.Value : Equatable { | |
/// Adds an action to perform when the gesture's value changes. | |
/// | |
/// - Parameter action: The action to perform when this gesture's value | |
/// changes. The `action` closure's parameter contains the gesture's new | |
/// value. | |
/// | |
/// - Returns: A gesture that triggers `action` when this gesture's value | |
/// changes. | |
public func onChanged(_ action: @escaping (Self.Value) -> Void) -> _ChangedGesture<Self> | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture { | |
/// Returns a gesture that's the result of mapping the given closure over | |
/// the gesture. | |
public func map<T>(_ body: @escaping (Self.Value) -> T) -> _MapGesture<Self, T> | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture { | |
/// Combines two gestures exclusively to create a new gesture where only one | |
/// gesture succeeds, giving precedence to the first gesture. | |
/// | |
/// - Parameter other: A gesture you combine with your gesture, to create a | |
/// new, combined gesture. | |
/// | |
/// - Returns: A gesture that's the result of combining two gestures where | |
/// only one of them can succeed. SwiftUI gives precedence to the first | |
/// gesture. | |
@inlinable public func exclusively<Other>(before other: Other) -> ExclusiveGesture<Self, Other> where Other : Gesture | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Gesture { | |
/// Updates the provided gesture state property as the gesture's value | |
/// changes. | |
/// | |
/// Use this callback to update transient UI state as described in | |
/// <doc:Adding-Interactivity-with-Gestures>. | |
/// | |
/// - Parameters: | |
/// - state: A binding to a view's ``GestureState`` property. | |
/// - body: The callback that SwiftUI invokes as the gesture's value | |
/// changes. Its `currentState` parameter is the updated state of the | |
/// gesture. The `gestureState` parameter is the previous state of the | |
/// gesture, and the `transaction` is the context of the gesture. | |
/// | |
/// - Returns: A version of the gesture that updates the provided `state` as | |
/// the originating gesture's value changes, and that resets the `state` | |
/// to its initial value when the users cancels or ends the gesture. | |
@inlinable public func updating<State>(_ state: GestureState<State>, body: @escaping (Self.Value, inout State, inout Transaction) -> Void) -> GestureStateGesture<Self, State> | |
} | |
/// Options that control how adding a gesture to a view affect's other gestures | |
/// recognized by the view and its subviews. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct GestureMask : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
public init(rawValue: UInt32) | |
/// Disable all gestures in the subview hierarchy, including the added | |
/// gesture. | |
public static let none: GestureMask | |
/// Enable the added gesture but disable all gestures in the subview | |
/// hierarchy. | |
public static let gesture: GestureMask | |
/// Enable all gestures in the subview hierarchy but disable the added | |
/// gesture. | |
public static let subviews: GestureMask | |
/// Enable both the added gesture as well as all other gestures on the view | |
/// and its subviews. | |
public static let all: GestureMask | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = GestureMask | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = GestureMask | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension GestureMask : Sendable { | |
} | |
/// A property wrapper type that updates a property while the user performs a | |
/// gesture and resets the property back to its initial state when the gesture | |
/// ends. | |
/// | |
/// Declare a property as `@GestureState`, pass as a binding to it as a | |
/// parameter to a gesture's ``Gesture/updating(_:body:)`` callback, and receive | |
/// updates to it. A property that's declared as `@GestureState` implicitly | |
/// resets when the gesture becomes inactive, making it suitable for tracking | |
/// transient state. | |
/// | |
/// Add a long-press gesture to a ``Circle``, and update the interface during | |
/// the gesture by declaring a property as `@GestureState`: | |
/// | |
/// struct SimpleLongPressGestureView: View { | |
/// @GestureState var isDetectingLongPress = false | |
/// | |
/// var longPress: some Gesture { | |
/// LongPressGesture(minimumDuration: 3) | |
/// .updating($isDetectingLongPress) { currentState, gestureState, transaction in | |
/// gestureState = currentState | |
/// } | |
/// } | |
/// | |
/// var body: some View { | |
/// Circle() | |
/// .fill(self.isDetectingLongPress ? Color.red : Color.green) | |
/// .frame(width: 100, height: 100, alignment: .center) | |
/// .gesture(longPress) | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@propertyWrapper @frozen public struct GestureState<Value> : DynamicProperty { | |
/// Creates a view state that's derived from a gesture. | |
/// | |
/// - Parameter wrappedValue: A wrapped value for the gesture state | |
/// property. | |
public init(wrappedValue: Value) | |
/// Creates a view state that's derived from a gesture with an initial | |
/// value. | |
/// | |
/// - Parameter initialValue: An initial value for the gesture state | |
/// property. | |
public init(initialValue: Value) | |
/// Creates a view state that's derived from a gesture with a wrapped state | |
/// value and a transaction to reset it. | |
/// | |
/// - Parameters: | |
/// - wrappedValue: A wrapped value for the gesture state property. | |
/// - resetTransaction: A transaction that provides metadata for view | |
/// updates. | |
public init(wrappedValue: Value, resetTransaction: Transaction) | |
/// Creates a view state that's derived from a gesture with an initial state | |
/// value and a transaction to reset it. | |
/// | |
/// - Parameters: | |
/// - initialValue: An initial state value. | |
/// - resetTransaction: A transaction that provides metadata for view | |
/// updates. | |
public init(initialValue: Value, resetTransaction: Transaction) | |
/// Creates a view state that's derived from a gesture with a wrapped state | |
/// value and a closure that provides a transaction to reset it. | |
/// | |
/// - Parameters: | |
/// - wrappedValue: A wrapped value for the gesture state property. | |
/// - reset: A closure that provides a ``Transaction``. | |
public init(wrappedValue: Value, reset: @escaping (Value, inout Transaction) -> Void) | |
/// Creates a view state that's derived from a gesture with an initial state | |
/// value and a closure that provides a transaction to reset it. | |
/// | |
/// - Parameters: | |
/// - initialValue: An initial state value. | |
/// - reset: A closure that provides a ``Transaction``. | |
public init(initialValue: Value, reset: @escaping (Value, inout Transaction) -> Void) | |
/// The wrapped value referenced by the gesture state property. | |
public var wrappedValue: Value { get } | |
/// A binding to the gesture state property. | |
public var projectedValue: GestureState<Value> { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension GestureState where Value : ExpressibleByNilLiteral { | |
/// Creates a view state that's derived from a gesture with a transaction to | |
/// reset it. | |
/// | |
/// - Parameter resetTransaction: A transaction that provides metadata for | |
/// view updates. | |
public init(resetTransaction: Transaction = Transaction()) | |
/// Creates a view state that's derived from a gesture with a closure that | |
/// provides a transaction to reset it. | |
/// | |
/// - Parameter reset: A closure that provides a ``Transaction``. | |
public init(reset: @escaping (Value, inout Transaction) -> Void) | |
} | |
/// A gesture that updates the state provided by a gesture's updating callback. | |
/// | |
/// A gesture's ``Gesture/updating(_:body:)`` callback returns a | |
/// `GestureStateGesture` instance for updating a transient state property | |
/// that's annotated with the ``GestureState`` property wrapper. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct GestureStateGesture<Base, State> : Gesture where Base : Gesture { | |
/// The type representing the gesture's value. | |
public typealias Value = Base.Value | |
/// The originating gesture. | |
public var base: Base | |
/// A value that changes as the user performs the gesture. | |
public var state: GestureState<State> | |
/// The updating gesture containing the originating gesture's value, the | |
/// updated state of the gesture, and a transaction. | |
public var body: (GestureStateGesture<Base, State>.Value, inout State, inout Transaction) -> Void | |
/// Creates a new gesture that's the result of an ongoing gesture. | |
/// | |
/// - Parameters: | |
/// - base: The originating gesture. | |
/// - state: The wrapped value of a ``GestureState`` property. | |
/// - body: The callback that SwiftUI invokes as the gesture's value | |
/// changes. | |
@inlinable public init(base: Base, state: GestureState<State>, body: @escaping (GestureStateGesture<Base, State>.Value, inout State, inout Transaction) -> Void) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
} | |
/// A color gradient represented as an array of color stops, each having a | |
/// parametric location value. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Gradient : Equatable { | |
/// One color stop in the gradient. | |
@frozen public struct Stop : Equatable { | |
/// The color for the stop. | |
public var color: Color | |
/// The parametric location of the stop. | |
/// | |
/// This value must be in the range `[0, 1]`. | |
public var location: CGFloat | |
/// Creates a color stop with a color and location. | |
public init(color: Color, location: CGFloat) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Gradient.Stop, b: Gradient.Stop) -> Bool | |
} | |
/// The array of color stops. | |
public var stops: [Gradient.Stop] | |
/// Creates a gradient from an array of color stops. | |
public init(stops: [Gradient.Stop]) | |
/// Creates a gradient from an array of colors. | |
/// | |
/// The gradient synthesizes its location values to evenly space the colors | |
/// along the gradient. | |
public init(colors: [Color]) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Gradient, b: Gradient) -> Bool | |
} | |
/// A date picker style that displays an interactive calendar or clock. | |
/// | |
/// Do not use this type directly. Instead, use ``DatePickerStyle/graphical``. | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct GraphicalDatePickerStyle : DatePickerStyle { | |
/// Creates an instance of the graphical date picker style. | |
public init() | |
} | |
/// An immediate mode drawing destination, and its current state. | |
/// | |
/// Use a context to execute 2D drawing primitives. For example, you can draw | |
/// filled shapes using the ``fill(_:with:style:)`` method inside a ``Canvas`` | |
/// view: | |
/// | |
/// Canvas { context, size in | |
/// context.fill( | |
/// Path(ellipseIn: CGRect(origin: .zero, size: size)), | |
/// with: .color(.green)) | |
/// } | |
/// .frame(width: 300, height: 200) | |
/// | |
/// The example above draws an ellipse that just fits inside a canvas that's | |
/// constrained to 300 points wide and 200 points tall: | |
/// | |
/// ![A screenshot of a view that shows a green ellipse.](GraphicsContext-1) | |
/// | |
/// In addition to outlining or filling paths, you can draw images, text, | |
/// and SwiftUI views. You can also use the context to perform many common | |
/// graphical operations, like adding masks, applying filters and | |
/// transforms, and setting a blend mode. For example you can add | |
/// a mask using the ``clip(to:style:options:)`` method: | |
/// | |
/// let halfSize = size.applying(CGAffineTransform(scaleX: 0.5, y: 0.5)) | |
/// context.clip(to: Path(CGRect(origin: .zero, size: halfSize))) | |
/// context.fill( | |
/// Path(ellipseIn: CGRect(origin: .zero, size: size)), | |
/// with: .color(.green)) | |
/// | |
/// The rectangular mask hides all but one quadrant of the ellipse: | |
/// | |
/// ![A screenshot of a view that shows the upper left quarter of a green | |
/// ellipse.](GraphicsContext-2) | |
/// | |
/// The order of operations matters. Changes that you make to the state of | |
/// the context, like adding a mask or a filter, apply to later | |
/// drawing operations. If you reverse the fill and clip operations in | |
/// the example above, so that the fill comes first, the mask doesn't | |
/// affect the ellipse. | |
/// | |
/// Each context references a particular layer in a tree of transparency layers, | |
/// and also contains a full copy of the drawing state. You can modify the | |
/// state of one context without affecting the state of any other, even if | |
/// they refer to the same layer. For example you can draw the masked ellipse | |
/// from the previous example into a copy of the main context, and then add a | |
/// rectangle into the main context: | |
/// | |
/// // Create a copy of the context to draw a clipped ellipse. | |
/// var maskedContext = context | |
/// let halfSize = size.applying(CGAffineTransform(scaleX: 0.5, y: 0.5)) | |
/// maskedContext.clip(to: Path(CGRect(origin: .zero, size: halfSize))) | |
/// maskedContext.fill( | |
/// Path(ellipseIn: CGRect(origin: .zero, size: size)), | |
/// with: .color(.green)) | |
/// | |
/// // Go back to the original context to draw the rectangle. | |
/// let origin = CGPoint(x: size.width / 4, y: size.height / 4) | |
/// context.fill( | |
/// Path(CGRect(origin: origin, size: halfSize)), | |
/// with: .color(.blue)) | |
/// | |
/// The mask doesn't clip the rectangle because the mask isn't part of the | |
/// main context. However, both contexts draw into the same view because | |
/// you created one context as a copy of the other: | |
/// | |
/// ![A screenshot of a view that shows the upper left quarter of a green | |
/// ellipse, overlaid by a blue rectangle centered in the | |
/// view.](GraphicsContext-3) | |
/// | |
/// The context has access to an ``EnvironmentValues`` instance called | |
/// ``environment`` that's initially copied from the environment of its | |
/// enclosing view. SwiftUI uses environment values --- like the display | |
/// resolution and color scheme --- to resolve types like ``Image`` and | |
/// ``Color`` that appear in the context. You can also access values stored | |
/// in the environment for your own purposes. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
@frozen public struct GraphicsContext { | |
/// The ways that a graphics context combines new content with background | |
/// content. | |
/// | |
/// Use one of these values to set the | |
/// ``GraphicsContext/blendMode-swift.property`` property of a | |
/// ``GraphicsContext``. The value that you set affects how content | |
/// that you draw replaces or combines with content that you | |
/// previously drew into the context. | |
/// | |
@frozen public struct BlendMode : RawRepresentable, Equatable { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: Int32 | |
/// Creates a new instance with the specified raw value. | |
/// | |
/// If there is no value of the type that corresponds with the specified raw | |
/// value, this initializer returns `nil`. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// print(PaperSize(rawValue: "Legal")) | |
/// // Prints "Optional("PaperSize.Legal")" | |
/// | |
/// print(PaperSize(rawValue: "Tabloid")) | |
/// // Prints "nil" | |
/// | |
/// - Parameter rawValue: The raw value to use for the new instance. | |
@inlinable public init(rawValue: Int32) | |
/// A mode that paints source image samples over the background image | |
/// samples. | |
/// | |
/// This is the default blend mode. | |
@inlinable public static var normal: GraphicsContext.BlendMode { get } | |
/// A mode that multiplies the source image samples with the background | |
/// image samples. | |
/// | |
/// Drawing in this mode results in colors that are at least as | |
/// dark as either of the two contributing sample colors. | |
@inlinable public static var multiply: GraphicsContext.BlendMode { get } | |
/// A mode that multiplies the inverse of the source image samples with | |
/// the inverse of the background image samples. | |
/// | |
/// Drawing in this mode results in colors that are at least as light | |
/// as either of the two contributing sample colors. | |
@inlinable public static var screen: GraphicsContext.BlendMode { get } | |
/// A mode that either multiplies or screens the source image samples | |
/// with the background image samples, depending on the background | |
/// color. | |
/// | |
/// Drawing in this mode overlays the existing image samples | |
/// while preserving the highlights and shadows of the | |
/// background. The background color mixes with the source | |
/// image to reflect the lightness or darkness of the | |
/// background. | |
@inlinable public static var overlay: GraphicsContext.BlendMode { get } | |
/// A mode that creates composite image samples by choosing the darker | |
/// samples from either the source image or the background. | |
/// | |
/// When you draw in this mode, source image samples that are darker | |
/// than the background replace the background. | |
/// Otherwise, the background image samples remain unchanged. | |
@inlinable public static var darken: GraphicsContext.BlendMode { get } | |
/// A mode that creates composite image samples by choosing the lighter | |
/// samples from either the source image or the background. | |
/// | |
/// When you draw in this mode, source image samples that are lighter | |
/// than the background replace the background. | |
/// Otherwise, the background image samples remain unchanged. | |
@inlinable public static var lighten: GraphicsContext.BlendMode { get } | |
/// A mode that brightens the background image samples to reflect the | |
/// source image samples. | |
/// | |
/// Source image sample values that | |
/// specify black do not produce a change. | |
@inlinable public static var colorDodge: GraphicsContext.BlendMode { get } | |
/// A mode that darkens background image samples to reflect the source | |
/// image samples. | |
/// | |
/// Source image sample values that specify | |
/// white do not produce a change. | |
@inlinable public static var colorBurn: GraphicsContext.BlendMode { get } | |
/// A mode that either darkens or lightens colors, depending on the | |
/// source image sample color. | |
/// | |
/// If the source image sample color is | |
/// lighter than 50% gray, the background is lightened, similar | |
/// to dodging. If the source image sample color is darker than | |
/// 50% gray, the background is darkened, similar to burning. | |
/// If the source image sample color is equal to 50% gray, the | |
/// background is not changed. Image samples that are equal to | |
/// pure black or pure white produce darker or lighter areas, | |
/// but do not result in pure black or white. The overall | |
/// effect is similar to what you'd achieve by shining a | |
/// diffuse spotlight on the source image. Use this to add | |
/// highlights to a scene. | |
@inlinable public static var softLight: GraphicsContext.BlendMode { get } | |
/// A mode that either multiplies or screens colors, depending on the | |
/// source image sample color. | |
/// | |
/// If the source image sample color | |
/// is lighter than 50% gray, the background is lightened, | |
/// similar to screening. If the source image sample color is | |
/// darker than 50% gray, the background is darkened, similar | |
/// to multiplying. If the source image sample color is equal | |
/// to 50% gray, the source image is not changed. Image samples | |
/// that are equal to pure black or pure white result in pure | |
/// black or white. The overall effect is similar to what you'd | |
/// achieve by shining a harsh spotlight on the source image. | |
/// Use this to add highlights to a scene. | |
@inlinable public static var hardLight: GraphicsContext.BlendMode { get } | |
/// A mode that subtracts the brighter of the source image sample color | |
/// or the background image sample color from the other. | |
/// | |
/// Source image sample values that are black produce no change; white | |
/// inverts the background color values. | |
@inlinable public static var difference: GraphicsContext.BlendMode { get } | |
/// A mode that produces an effect similar to that produced by the | |
/// difference blend mode, but with lower contrast. | |
/// | |
/// Source image sample values that are black don't produce a change; | |
/// white inverts the background color values. | |
@inlinable public static var exclusion: GraphicsContext.BlendMode { get } | |
/// A mode that uses the luminance and saturation values of the | |
/// background with the hue of the source image. | |
@inlinable public static var hue: GraphicsContext.BlendMode { get } | |
/// A mode that uses the luminance and hue values of the background with | |
/// the saturation of the source image. | |
/// | |
/// Areas of the background that have no saturation --- namely, | |
/// pure gray areas --- don't produce a change. | |
@inlinable public static var saturation: GraphicsContext.BlendMode { get } | |
/// A mode that uses the luminance values of the background with the hue | |
/// and saturation values of the source image. | |
/// | |
/// This mode preserves the gray levels in the image. You can use this | |
/// mode to color monochrome images or to tint color images. | |
@inlinable public static var color: GraphicsContext.BlendMode { get } | |
/// A mode that uses the hue and saturation of the background with the | |
/// luminance of the source image. | |
/// | |
/// This mode creates an effect that is inverse to the effect created | |
/// by the ``color`` mode. | |
@inlinable public static var luminosity: GraphicsContext.BlendMode { get } | |
/// A mode that clears any pixels that the source image overwrites. | |
/// | |
/// With this mode, you can use the source image like an eraser. | |
/// | |
/// This mode implements the equation `R = 0` where | |
/// `R` is the composite image. | |
@inlinable public static var clear: GraphicsContext.BlendMode { get } | |
/// A mode that replaces background image samples with source image | |
/// samples. | |
/// | |
/// Unlike the ``normal`` mode, the source image completely replaces | |
/// the background, so that even transparent pixels in the source image | |
/// replace opaque pixels in the background, rather than letting the | |
/// background show through. | |
/// | |
/// This mode implements the equation `R = S` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
@inlinable public static var copy: GraphicsContext.BlendMode { get } | |
/// A mode that you use to paint the source image, including | |
/// its transparency, onto the opaque parts of the background. | |
/// | |
/// This mode implements the equation `R = S*Da` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `Da` is the source background's alpha value. | |
@inlinable public static var sourceIn: GraphicsContext.BlendMode { get } | |
/// A mode that you use to paint the source image onto the | |
/// transparent parts of the background, while erasing the background. | |
/// | |
/// This mode implements the equation `R = S*(1 - Da)` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `Da` is the source background's alpha value. | |
@inlinable public static var sourceOut: GraphicsContext.BlendMode { get } | |
/// A mode that you use to paint the opaque parts of the | |
/// source image onto the opaque parts of the background. | |
/// | |
/// This mode implements the equation `R = S*Da + D*(1 - Sa)` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `D` is the background. | |
/// * `Sa` is the source image's alpha value. | |
/// * `Da` is the source background's alpha value. | |
@inlinable public static var sourceAtop: GraphicsContext.BlendMode { get } | |
/// A mode that you use to paint the source image under | |
/// the background. | |
/// | |
/// This mode implements the equation `R = S*(1 - Da) + D` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `D` is the background. | |
/// * `Da` is the source background's alpha value. | |
@inlinable public static var destinationOver: GraphicsContext.BlendMode { get } | |
/// A mode that you use to erase any of the background that | |
/// isn't covered by opaque source pixels. | |
/// | |
/// This mode implements the equation `R = D*Sa` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `Da` is the source background's alpha value. | |
@inlinable public static var destinationIn: GraphicsContext.BlendMode { get } | |
/// A mode that you use to erase any of the background that | |
/// is covered by opaque source pixels. | |
/// | |
/// This mode implements the equation `R = D*(1 - Sa)` where | |
/// * `R` is the composite image. | |
/// * `D` is the background. | |
/// * `Sa` is the source image's alpha value. | |
@inlinable public static var destinationOut: GraphicsContext.BlendMode { get } | |
/// A mode that you use to paint the source image under | |
/// the background, while erasing any of the background not matched | |
/// by opaque pixels from the source image. | |
/// | |
/// This mode implements the equation `R = S*(1 - Da) + D*Sa` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `D` is the background. | |
/// * `Sa` is the source image's alpha value. | |
/// * `Da` is the source background's alpha value. | |
@inlinable public static var destinationAtop: GraphicsContext.BlendMode { get } | |
/// A mode that you use to clear pixels where both the source and | |
/// background images are opaque. | |
/// | |
/// This mode implements the equation `R = S*(1 - Da) + D*(1 - Sa)` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `D` is the background. | |
/// * `Sa` is the source image's alpha value. | |
/// * `Da` is the source background's alpha value. | |
/// | |
/// This XOR mode is only nominally related to the classical bitmap | |
/// XOR operation, which SwiftUI doesn't support. | |
@inlinable public static var xor: GraphicsContext.BlendMode { get } | |
/// A mode that adds the inverse of the color components of the source | |
/// and background images, and then inverts the result, producing | |
/// a darkened composite. | |
/// | |
/// This mode implements the equation `R = MAX(0, 1 - ((1 - D) + (1 - S)))` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `D` is the background. | |
@inlinable public static var plusDarker: GraphicsContext.BlendMode { get } | |
/// A mode that adds the components of the source and background images, | |
/// resulting in a lightened composite. | |
/// | |
/// This mode implements the equation `R = MIN(1, S + D)` where | |
/// * `R` is the composite image. | |
/// * `S` is the source image. | |
/// * `D` is the background. | |
@inlinable public static var plusLighter: GraphicsContext.BlendMode { get } | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int32 | |
} | |
/// The opacity of drawing operations in the context. | |
/// | |
/// Set this value to affect the opacity of content that you subsequently | |
/// draw into the context. Changing this value has no impact on the | |
/// content you previously drew into the context. | |
public var opacity: Double | |
/// The blend mode used by drawing operations in the context. | |
/// | |
/// Set this value to affect how any content that you subsequently draw | |
/// into the context blends with content that's already in the context. | |
/// Use one of the ``GraphicsContext/BlendMode-swift.struct`` values. | |
public var blendMode: GraphicsContext.BlendMode | |
/// The environment associated with the graphics context. | |
/// | |
/// SwiftUI initially sets this to the environment of the context's | |
/// enclosing view. The context uses values like display | |
/// resolution and teh color scheme from the environment to resolve types | |
/// like ``Image`` and ``Color``. You can also access values stored in the | |
/// environment for your own purposes. | |
public var environment: EnvironmentValues { get } | |
/// The current transform matrix, defining user space coordinates. | |
/// | |
/// Modify this matrix to transform content that you subsequently | |
/// draw into the context. Changes that you make don't affect | |
/// existing content. | |
public var transform: CGAffineTransform | |
/// Scales subsequent drawing operations by an amount in each dimension. | |
/// | |
/// Calling this method is equivalent to updating the context's | |
/// ``transform`` directly using the given scale factors: | |
/// | |
/// transform = transform.scaledBy(x: x, y: y) | |
/// | |
/// - Parameters: | |
/// - x: The amount to scale in the horizontal direction. | |
/// - y: The amount to scale in the vertical direction. | |
public mutating func scaleBy(x: CGFloat, y: CGFloat) | |
/// Moves subsequent drawing operations by an amount in each dimension. | |
/// | |
/// Calling this method is equivalent to updating the context's | |
/// ``transform`` directly using the given translation amount: | |
/// | |
/// transform = transform.translatedBy(x: x, y: y) | |
/// | |
/// - Parameters: | |
/// - x: The amount to move in the horizontal direction. | |
/// - y: The amount to move in the vertical direction. | |
public mutating func translateBy(x: CGFloat, y: CGFloat) | |
/// Rotates subsequent drawing operations by an angle. | |
/// | |
/// Calling this method is equivalent to updating the context's | |
/// ``transform`` directly using the `angle` parameter: | |
/// | |
/// transform = transform.rotated(by: angle.radians) | |
/// | |
/// - Parameters: | |
/// - angle: The amount to rotate. | |
public mutating func rotate(by angle: Angle) | |
/// Appends the given transform to the context's existing transform. | |
/// | |
/// Calling this method is equivalent to updating the context's | |
/// ``transform`` directly using the `matrix` parameter: | |
/// | |
/// transform = matrix.concatenating(transform) | |
/// | |
/// - Parameter matrix: A transform to append to the existing transform. | |
public mutating func concatenate(_ matrix: CGAffineTransform) | |
/// Options that affect the use of clip shapes. | |
/// | |
/// Use these options to affect how SwiftUI interprets a clip shape | |
/// when you call ``clip(to:style:options:)`` to add a path to the array of | |
/// clip shapes, or when you call ``clipToLayer(opacity:options:content:)`` | |
/// to add a clipping layer. | |
@frozen public struct ClipOptions : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt32) | |
/// An option to invert the shape or layer alpha as the clip mask. | |
/// | |
/// When you use this option, SwiftUI uses `1 - alpha` instead of | |
/// `alpha` for the given clip shape. | |
@inlinable public static var inverse: GraphicsContext.ClipOptions { get } | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = GraphicsContext.ClipOptions | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = GraphicsContext.ClipOptions | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
/// The bounding rectangle of the intersection of all current clip | |
/// shapes in the current user space. | |
public var clipBoundingRect: CGRect { get } | |
/// Adds a path to the context's array of clip shapes. | |
/// | |
/// Call this method to add a shape to the array of clip shapes that | |
/// the context uses to define a clipping mask. Shapes that you add | |
/// affect only subsequent drawing operations. | |
/// | |
/// - Parameters: | |
/// - path: A ``Path`` that defines the shape of the clipping mask. | |
/// - style: A ``FillStyle`` that defines how to rasterize the shape. | |
/// - options: Clip options that tell SwiftUI how to interpret the `path` | |
/// as a clip shape. For example, you can invert the clip | |
/// shape by setting the ``ClipOptions/inverse`` option. | |
public mutating func clip(to path: Path, style: FillStyle = FillStyle(), options: GraphicsContext.ClipOptions = ClipOptions()) | |
/// Adds a clip shape that you define in a new layer to the context's array | |
/// of clip shapes. | |
/// | |
/// Call this method to add a shape to the array of clip shapes that | |
/// the context uses to define a clipping mask. Shapes that you add | |
/// affect only subsequent drawing operations. | |
/// | |
/// - Parameters: | |
/// - opacity: A value that SwiftUI uses to multiply the alpha channel of | |
/// the rasterized layer that you define in the `content` closure. The | |
/// alpha values that result define the clip shape. | |
/// - options: A set of options that tell SwiftUI how to interpret the | |
/// clip shape. For example, you can invert the clip | |
/// shape by setting the ``ClipOptions/inverse`` option. | |
/// - content: A closure that receives as input a new ``GraphicsContext``, | |
/// which represents a new transparency layer. The alpha channel of | |
/// content that you draw into this context, multiplied by the `opacity` | |
/// parameter, defines the clip shape. | |
public mutating func clipToLayer(opacity: Double = 1, options: GraphicsContext.ClipOptions = ClipOptions(), content: (inout GraphicsContext) throws -> Void) rethrows | |
/// A type that applies image processing operations to rendered content. | |
/// | |
/// Create and configure a filter that produces an image processing effect, | |
/// like adding a drop shadow or a blur effect, by calling one of the | |
/// factory methods defined by the `Filter` structure. Call the | |
/// ``addFilter(_:options:)`` method to add the filter to a | |
/// ``GraphicsContext``. The filter only affects content that you draw | |
/// into the context after adding the filter. | |
public struct Filter { | |
/// Returns a filter that that transforms the rasterized form | |
/// of subsequent graphics primitives. | |
/// | |
/// - Parameters: | |
/// - matrix: A projection transform to apply to the rasterized | |
/// form of graphics primitives. | |
/// - Returns: A filter that applies a transform. | |
public static func projectionTransform(_ matrix: ProjectionTransform) -> GraphicsContext.Filter | |
/// Returns a filter that adds a shadow. | |
/// | |
/// SwiftUI produces the shadow by blurring the alpha channel of the | |
/// object receiving the shadow, multiplying the result by a color, | |
/// optionally translating the shadow by an amount, | |
/// and then blending the resulting shadow into a new layer below the | |
/// source primitive. You can customize some of these steps by adding | |
/// one or more shadow options. | |
/// | |
/// - Parameters: | |
/// - color: A ``Color`` that tints the shadow. | |
/// - radius: A measure of how far the shadow extends from the edges | |
/// of the content receiving the shadow. | |
/// - x: An amount to translate the shadow horizontally. | |
/// - y: An amount to translate the shadow vertically. | |
/// - blendMode: The ``GraphicsContext/BlendMode-swift.struct`` to use | |
/// when blending the shadow into the background layer. | |
/// - options: A set of options that you can use to customize the | |
/// process of adding the shadow. Use one or more of the options | |
/// in ``GraphicsContext/ShadowOptions``. | |
/// - Returns: A filter that adds a shadow style. | |
public static func shadow(color: Color = Color(.sRGBLinear, white: 0, opacity: 0.33), radius: CGFloat, x: CGFloat = 0, y: CGFloat = 0, blendMode: GraphicsContext.BlendMode = .normal, options: GraphicsContext.ShadowOptions = ShadowOptions()) -> GraphicsContext.Filter | |
/// Returns a filter that multiplies each color component by | |
/// the matching component of a given color. | |
/// | |
/// - Parameters: | |
/// - color: The color that the filter uses for the multiplication | |
/// operation. | |
/// - Returns: A filter that multiplies color components. | |
public static func colorMultiply(_ color: Color) -> GraphicsContext.Filter | |
/// Returns a filter that multiplies by a given color matrix. | |
/// | |
/// This filter is equivalent to the `feColorMatrix` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// | |
/// The filter creates the output color `[R', G', B', A']` at each pixel | |
/// from an input color `[R, G, B, A]` by multiplying the input color by | |
/// the square matrix formed by the first four columns of the | |
/// ``ColorMatrix``, then adding the fifth column to the result: | |
/// | |
/// R' = r1 ✕ R + r2 ✕ G + r3 ✕ B + r4 ✕ A + r5 | |
/// G' = g1 ✕ R + g2 ✕ G + g3 ✕ B + g4 ✕ A + g5 | |
/// B' = b1 ✕ R + b2 ✕ G + b3 ✕ B + b4 ✕ A + b5 | |
/// A' = a1 ✕ R + a2 ✕ G + a3 ✕ B + a4 ✕ A + a5 | |
/// | |
/// - Parameters: | |
/// - matrix: A ``ColorMatrix`` instance used by the filter. | |
/// - Returns: A filter that transforms color using the given matrix. | |
public static func colorMatrix(_ matrix: ColorMatrix) -> GraphicsContext.Filter | |
/// Returns a filter that applies a hue rotation adjustment. | |
/// | |
/// This filter is equivalent to the `hue-rotate` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// | |
/// - Parameters: | |
/// - angle: The amount by which to rotate the hue value of each | |
/// pixel. | |
/// - Returns: A filter that applies a hue rotation adjustment. | |
public static func hueRotation(_ angle: Angle) -> GraphicsContext.Filter | |
/// Returns a filter that applies a saturation adjustment. | |
/// | |
/// This filter is equivalent to the `saturate` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// | |
/// - Parameters: | |
/// - amount: The amount of the saturation adjustment. A value | |
/// of zero to completely desaturates each pixel, while a value of | |
/// one makes no change. You can use values greater than one. | |
/// - Returns: A filter that applies a saturation adjustment. | |
public static func saturation(_ amount: Double) -> GraphicsContext.Filter | |
/// Returns a filter that applies a brightness adjustment. | |
/// | |
/// This filter is different than `brightness` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// You can obtain an effect like that filter using a ``grayscale(_:)`` | |
/// color multiply. However, this filter does match the | |
/// <doc://com.apple.documentation/documentation/CoreImage/CIColorControls> | |
/// filter's brightness adjustment. | |
/// | |
/// - Parameters: | |
/// - amount: An amount to add to the pixel's color components. | |
/// - Returns: A filter that applies a brightness adjustment. | |
public static func brightness(_ amount: Double) -> GraphicsContext.Filter | |
/// Returns a filter that applies a contrast adjustment. | |
/// | |
/// This filter is equivalent to the `contrast` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// | |
/// - Parameters: | |
/// - amount: An amount to adjust the contrast. A value of | |
/// zero leaves the result completely gray. A value of one leaves | |
/// the result unchanged. You can use values greater than one. | |
/// - Returns: A filter that applies a contrast adjustment. | |
public static func contrast(_ amount: Double) -> GraphicsContext.Filter | |
/// Returns a filter that inverts the color of their results. | |
/// | |
/// This filter is equivalent to the `invert` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// | |
/// - Parameters: | |
/// - amount: The inversion amount. A value of one results in total | |
/// inversion, while a value of zero leaves the result unchanged. | |
/// Other values apply a linear multiplier effect. | |
/// - Returns: A filter that applies a color inversion. | |
public static func colorInvert(_ amount: Double = 1) -> GraphicsContext.Filter | |
/// Returns a filter that applies a grayscale adjustment. | |
/// | |
/// This filter is equivalent to the `grayscale` filter primitive | |
/// defined by the Scalable Vector Graphics (SVG) specification. | |
/// | |
/// - Parameters: | |
/// - amount: An amount that controls the effect. A value of one | |
/// makes the image completely gray. A value of zero leaves the | |
/// result unchanged. Other values apply a linear multiplier effect. | |
/// - Returns: A filter that applies a grayscale adjustment. | |
public static func grayscale(_ amount: Double) -> GraphicsContext.Filter | |
/// Returns a filter that sets the opacity of each pixel based on its | |
/// luminance. | |
/// | |
/// The filter computes the luminance of each pixel | |
/// and uses it to define the opacity of the result, combined | |
/// with black (zero) color components. | |
/// | |
/// - Returns: A filter that applies a luminance to alpha transformation. | |
public static var luminanceToAlpha: GraphicsContext.Filter { get } | |
/// Returns a filter that applies a Gaussian blur. | |
/// | |
/// - Parameters: | |
/// - radius: The standard deviation of the Gaussian blur. | |
/// - options: A set of options controlling the application of the | |
/// effect. | |
/// - Returns: A filter that applies Gaussian blur. | |
public static func blur(radius: CGFloat, options: GraphicsContext.BlurOptions = BlurOptions()) -> GraphicsContext.Filter | |
/// Returns a filter that replaces each pixel with alpha components | |
/// within a range by a constant color, or transparency otherwise. | |
/// | |
/// - Parameters: | |
/// - min: The minimum alpha threshold. Pixels whose alpha | |
/// component is less than this value will render as | |
/// transparent. Results are undefined unless `min < max`. | |
/// - max: The maximum alpha threshold. Pixels whose alpha | |
/// component is greater than this value will render | |
/// as transparent. Results are undefined unless `min < max`. | |
/// - color: The color that is output for pixels with an alpha | |
/// component between the two threshold values. | |
/// - Returns: A filter that applies a threshold to alpha values. | |
public static func alphaThreshold(min: Double, max: Double = 1, color: Color = Color.black) -> GraphicsContext.Filter | |
} | |
/// Options that configure the graphics context filter that creates shadows. | |
/// | |
/// You can use a set of these options when you call | |
/// ``Filter/shadow(color:radius:x:y:blendMode:options:)`` to create a | |
/// ``Filter`` that adds a drop shadow to an object that you draw into a | |
/// ``GraphicsContext``. | |
@frozen public struct ShadowOptions : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt32) | |
/// An option that causes the filter to draw the shadow above the | |
/// object, rather than below it. | |
@inlinable public static var shadowAbove: GraphicsContext.ShadowOptions { get } | |
/// An option that causes the filter to draw only the shadow, and | |
/// omit the source object. | |
@inlinable public static var shadowOnly: GraphicsContext.ShadowOptions { get } | |
/// An option that causes the filter to invert the alpha of the shadow. | |
/// | |
/// You can create an "inner shadow" effect by combining this option | |
/// with ``shadowAbove`` and using the | |
/// ``GraphicsContext/BlendMode-swift.struct/sourceAtop`` blend mode. | |
@inlinable public static var invertsAlpha: GraphicsContext.ShadowOptions { get } | |
/// An option that causes the filter to composite the object and its | |
/// shadow separately in the current layer. | |
@inlinable public static var disablesGroup: GraphicsContext.ShadowOptions { get } | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = GraphicsContext.ShadowOptions | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = GraphicsContext.ShadowOptions | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
/// Options that configure the graphics context filter that creates blur. | |
/// | |
/// You can use a set of these options when you call | |
/// ``Filter/blur(radius:options:)`` to create a ``Filter`` that adds | |
/// blur to an object that you draw into a ``GraphicsContext``. | |
@frozen public struct BlurOptions : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt32) | |
/// An option that causes the filter to ensure the result is completely | |
/// opaque. | |
/// | |
/// The filter ensure opacity by dividing each pixel by its alpha | |
/// value. The result may be undefined if the input to the filter | |
/// isn't also completely opaque. | |
@inlinable public static var opaque: GraphicsContext.BlurOptions { get } | |
/// An option that causes the filter to dither the result, to reduce | |
/// banding. | |
@inlinable public static var dithersResult: GraphicsContext.BlurOptions { get } | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = GraphicsContext.BlurOptions | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = GraphicsContext.BlurOptions | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
/// Options that configure a filter that you add to a graphics context. | |
/// | |
/// You can use filter options to configure a ``Filter`` that you apply | |
/// to a ``GraphicsContext`` with the ``addFilter(_:options:)`` method. | |
@frozen public struct FilterOptions : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt32) | |
/// An option that causes the filter to perform calculations in a | |
/// linear color space. | |
@inlinable public static var linearColor: GraphicsContext.FilterOptions { get } | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = GraphicsContext.FilterOptions | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = GraphicsContext.FilterOptions | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
/// Adds a filter that applies to subsequent drawing operations. | |
/// | |
/// To draw with filtering, SwiftUI: | |
/// | |
/// - Rasterizes the drawing operation to an implicit transparency layer | |
/// without blending, adjusting opacity, or applying any clipping. | |
/// - Applies the filter to the layer containing the rasterized image. | |
/// - Composites the layer onto the background, using the context's | |
/// current blend mode, opacity setting, and clip shapes. | |
/// | |
/// When SwiftUI draws with a filter, the blend mode might apply to regions | |
/// outside the drawing operation's intrinsic shape, but inside its clip | |
/// shape. That might result in unexpected behavior for certain blend | |
/// modes like ``GraphicsContext/BlendMode-swift.struct/copy``, where | |
/// the drawing operation completely overwrites the background even if | |
/// the source alpha is zero. | |
/// | |
/// - Parameters: | |
/// - filter: A graphics context filter that you create by calling one | |
/// of the ``Filter`` factory methods. | |
/// - options: A set of options from ``FilterOptions`` that you can use to | |
/// configure filter operations. | |
public mutating func addFilter(_ filter: GraphicsContext.Filter, options: GraphicsContext.FilterOptions = FilterOptions()) | |
/// A color or pattern that you can use to outline or fill a path. | |
/// | |
/// Use a shading instance to describe the color or pattern of a path that | |
/// you outline with a method like ``stroke(_:with:style:)``, or of the | |
/// interior of a region that you fill with the ``fill(_:with:style:)`` | |
/// method. Get a shading instance by calling one of the `Shading` | |
/// structure's factory methods. You can base shading on: | |
/// - A ``Color``. | |
/// - A ``Gradient``. | |
/// - Any type that conforms to ``ShapeStyle``. | |
/// - An ``Image``. | |
/// - What you've already drawn into the context. | |
/// - A collection of other shading instances. | |
public struct Shading { | |
/// A shading instance that draws a copy of the current background. | |
public static var backdrop: GraphicsContext.Shading { get } | |
/// A shading instance that fills with the foreground style from | |
/// the graphics context's environment. | |
public static var foreground: GraphicsContext.Shading { get } | |
/// Returns a multilevel shading instance constructed from an | |
/// array of shading instances. | |
/// | |
/// - Parameter array: An array of shading instances. The array must | |
/// contain at least one element. | |
/// - Returns: A shading instance composed from the given instances. | |
public static func palette(_ array: [GraphicsContext.Shading]) -> GraphicsContext.Shading | |
/// Returns a shading instance that fills with a color. | |
/// | |
/// - Parameter color: A ``Color`` instance that defines the color | |
/// of the shading. | |
/// - Returns: A shading instance filled with a color. | |
public static func color(_ color: Color) -> GraphicsContext.Shading | |
/// Returns a shading instance that fills with a color in the given | |
/// color space. | |
/// | |
/// - Parameters: | |
/// - colorSpace: The RGB color space used to define the color. The | |
/// default is ``Color/RGBColorSpace/sRGB``. | |
/// - red: The red component of the color. | |
/// - green: The green component of the color. | |
/// - blue: The blue component of the color. | |
/// - opacity: The opacity of the color. The default is `1`, which | |
/// means fully opaque. | |
/// - Returns: A shading instance filled with a color. | |
public static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, red: Double, green: Double, blue: Double, opacity: Double = 1) -> GraphicsContext.Shading | |
/// Returns a shading instance that fills with a monochrome color in | |
/// the given color space. | |
/// | |
/// - Parameters: | |
/// - colorSpace: The RGB color space used to define the color. The | |
/// default is ``Color/RGBColorSpace/sRGB``. | |
/// - white: The value to use for each of the red, green, and blue | |
/// components of the color. | |
/// - opacity: The opacity of the color. The default is `1`, which | |
/// means fully opaque. | |
/// - Returns: A shading instance filled with a color. | |
public static func color(_ colorSpace: Color.RGBColorSpace = .sRGB, white: Double, opacity: Double = 1) -> GraphicsContext.Shading | |
/// Returns a shading instance that fills with the given shape style. | |
/// | |
/// Styles with geometry defined in a unit coordinate space | |
/// map that space to the rectangle associated with the drawn | |
/// object. You can adjust that using the ``ShapeStyle/in`(_:)`` | |
/// method. The shape style might affect the blend mode and opacity | |
/// of the drawn object. | |
/// | |
/// - Parameter style: A ``ShapeStyle`` instance to draw with. | |
/// - Returns: A shading instance filled with a shape style. | |
public static func style<S>(_ style: S) -> GraphicsContext.Shading where S : ShapeStyle | |
/// Returns a shading instance that fills a linear (axial) gradient. | |
/// | |
/// The shading instance defines an axis from `startPoint` to `endPoint` | |
/// in the current user space and maps colors from `gradient` | |
/// to lines perpendicular to the axis. | |
/// | |
/// - Parameters: | |
/// - gradient: A ``Gradient`` instance that defines the colors | |
/// of the gradient. | |
/// - startPoint: The start point of the gradient axis. | |
/// - endPoint: The end point of the gradient axis. | |
/// - options: Options that you use to configure the gradient. | |
/// - Returns: A shading instance filled with a linear gradient. | |
public static func linearGradient(_ gradient: Gradient, startPoint: CGPoint, endPoint: CGPoint, options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading | |
/// Returns a shading instance that fills a radial gradient. | |
/// | |
/// - Parameters: | |
/// - gradient: A ``Gradient`` instance that defines the colors | |
/// of the gradient. | |
/// - center: The point in the current user space on which SwiftUI | |
/// centers the gradient. | |
/// - startRadius: The distance from the center where the gradient | |
/// starts. | |
/// - endRadius:The distance from the center where the gradient ends. | |
/// - options: Options that you use to configure the gradient. | |
/// - Returns: A shading instance filled with a radial gradient. | |
public static func radialGradient(_ gradient: Gradient, center: CGPoint, startRadius: CGFloat, endRadius: CGFloat, options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading | |
/// Returns a shading instance that fills a conic (angular) gradient. | |
/// | |
/// - Parameters: | |
/// - gradient: A ``Gradient`` instance that defines the colors | |
/// of the gradient. | |
/// - center: The point in the current user space on which SwiftUI | |
/// centers the gradient. | |
/// - angle: The angle about the center that SwiftUI uses to start and | |
/// finish the gradient. The gradient sweeps all the way around the | |
/// center. | |
/// - options: Options that you use to configure the gradient. | |
/// - Returns: A shading instance filled with a conic gradient. | |
public static func conicGradient(_ gradient: Gradient, center: CGPoint, angle: Angle = Angle(), options: GraphicsContext.GradientOptions = GradientOptions()) -> GraphicsContext.Shading | |
/// Returns a shading instance that tiles an image across the infinite | |
/// plane. | |
/// | |
/// - Parameters: | |
/// - image: An ``Image`` to use as fill. | |
/// - origin: The point in the current user space where SwiftUI | |
/// places the bottom left corner of the part of the image | |
/// defined by `sourceRect`. The image repeats as needed. | |
/// - sourceRect: A unit space subregion of the image. The default | |
/// is a unit rectangle, which selects the whole image. | |
/// - scale: A factor that you can use to control the image size. | |
/// - Returns: A shading instance filled with a tiled image. | |
public static func tiledImage(_ image: Image, origin: CGPoint = .zero, sourceRect: CGRect = CGRect(x: 0, y: 0, width: 1, height: 1), scale: CGFloat = 1) -> GraphicsContext.Shading | |
} | |
/// Options that affect the rendering of color gradients. | |
/// | |
/// Use these options to affect how SwiftUI manages a gradient that you | |
/// create for a ``Shading`` instance for use in a ``GraphicsContext``. | |
@frozen public struct GradientOptions : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt32) | |
/// An option that repeats the gradient outside its nominal range. | |
/// | |
/// Use this option to cause the gradient to repeat its pattern in | |
/// areas that exceed the bounds of its start and end points. | |
/// The repetitions use the same start and end value for each | |
/// repetition. | |
/// | |
/// Without this option or ``mirror``, the gradient stops at | |
/// the end of its range. The ``mirror`` option takes precendence if | |
/// you set both this one and that one. | |
@inlinable public static var `repeat`: GraphicsContext.GradientOptions { get } | |
/// An option that repeats the gradient outside its nominal range, | |
/// reflecting every other instance. | |
/// | |
/// Use this option to cause the gradient to repeat its pattern in | |
/// areas that exceed the bounds of its start and end points. | |
/// The repetitions alternately reverse the start and end points, | |
/// producing a pattern like `0 -> 1`, `1 -> 0`, `0 -> 1`, and so on. | |
/// | |
/// Without either this option or ``repeat``, the gradient stops at | |
/// the end of its range. This option takes precendence if | |
/// you set both this one and ``repeat``. | |
@inlinable public static var mirror: GraphicsContext.GradientOptions { get } | |
/// An option that interpolates between colors in a linear color space. | |
@inlinable public static var linearColor: GraphicsContext.GradientOptions { get } | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = GraphicsContext.GradientOptions | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = GraphicsContext.GradientOptions | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
/// Returns a version of a shading resolved with the current values | |
/// of the graphics context's environment. | |
/// | |
/// Calling this function once and then drawing multiple times with | |
/// the result will often have less overhead than drawing with the | |
/// original shading multiple times. | |
public func resolve(_ shading: GraphicsContext.Shading) -> GraphicsContext.Shading | |
/// Draws a new layer, created by drawing code that you provide, into the | |
/// context. | |
/// | |
/// - Parameter context: A closure that receives a new ``GraphicsContext`` | |
/// as input. This context represents a new transparency layer that you | |
/// can draw into. When the closure returns, SwiftUI draws the new layer | |
/// into the current context. | |
public func drawLayer(content: (inout GraphicsContext) throws -> Void) rethrows | |
/// Draws a path into the context and fills the outlined region. | |
/// | |
/// The current drawing state of the context defines the | |
/// full drawing operation. For example, the current transformation and | |
/// clip shapes, and any styles applied to the result, affect the final | |
/// result. | |
/// | |
/// - Parameters: | |
/// - path: The outline of the region to fill. | |
/// - shading: The color or pattern to use when filling the region | |
/// bounded by `path`. | |
/// - style: A style that indicates how to rasterize the path. | |
public func fill(_ path: Path, with shading: GraphicsContext.Shading, style: FillStyle = FillStyle()) | |
/// Draws a path into the context with a specified stroke style. | |
/// | |
/// If you only need to control the style's ``StrokeStyle/lineWidth`` | |
/// property, use ``stroke(_:with:lineWidth:)`` instead. | |
/// | |
/// - Parameters: | |
/// - path: The path to outline. | |
/// - shading: The color or pattern to use when outlining the `path`. | |
/// - style: A style that indicates how to outline the path. | |
public func stroke(_ path: Path, with shading: GraphicsContext.Shading, style: StrokeStyle) | |
/// Draws a path into the context with a specified line width. | |
/// | |
/// When you call this method, all ``StrokeStyle`` properties other than | |
/// ``StrokeStyle/lineWidth`` take their default values. To control other | |
/// style properties, use ``stroke(_:with:style:)`` instead. | |
/// | |
/// - Parameters: | |
/// - path: The path to outline. | |
/// - shading: The color or pattern to use when outlining the `path`. | |
/// - lineWidth: The width of the stroke, which defaults to `1`. | |
public func stroke(_ path: Path, with shading: GraphicsContext.Shading, lineWidth: CGFloat = 1) | |
/// An image resolved to a particular environment. | |
/// | |
/// You resolve an ``Image`` in preparation for drawing it into a context, | |
/// either manually by calling ``resolve(_:)-898z6``, or automatically | |
/// when calling ``draw(_:in:style:)-blhz`` or ``draw(_:at:anchor:)-1z5wt``. | |
/// The resolved image takes into account environment values like the | |
/// display resolution and current color scheme. | |
public struct ResolvedImage { | |
/// The size of the image. | |
public var size: CGSize { get } | |
/// The distance from the top of the image to its baseline. | |
/// | |
/// If the image has no baseline, this value is equivalent to the | |
/// image's height. | |
public let baseline: CGFloat | |
/// An optional shading to fill the image with. | |
/// | |
/// The value of this property defaults to | |
/// ``GraphicsContext/Shading/foreground`` for template images, and | |
/// to `nil` otherwise. | |
public var shading: GraphicsContext.Shading? | |
} | |
/// Gets a version of an image that's fixed with the current values of | |
/// the graphics context's environment. | |
/// | |
/// You can measure the resolved image by looking at its | |
/// ``ResolvedImage/size`` and ``ResolvedImage/baseline`` properties. | |
/// You can draw the resolved image with the context's | |
/// ``draw(_:in:style:)-7rvee`` or ``draw(_:at:anchor:)-1z5wt`` method. | |
/// | |
/// - Parameter image: The ``Image`` to resolve. | |
/// - Returns: An image that's resolved into the current context's | |
/// environment, taking into account environment values like the | |
/// display resolution and current color scheme. | |
public func resolve(_ image: Image) -> GraphicsContext.ResolvedImage | |
/// Draws a resolved image into the context, using the specified rectangle | |
/// as a layout frame. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the image. | |
/// | |
/// - Parameters: | |
/// - image: The ``ResolvedImage`` to draw. Get a resolved image from an | |
/// ``Image`` by calling ``resolve(_:)-898z6``. Alternatively, you can | |
/// call ``draw(_:in:style:)-blhz`` with an ``Image``, and that method | |
/// performs the resolution automatically. | |
/// - rect: The rectangle in the current user space to draw the image in. | |
/// - style: A fill style to use when rasterizing the image. | |
public func draw(_ image: GraphicsContext.ResolvedImage, in rect: CGRect, style: FillStyle = FillStyle()) | |
/// Draws a resolved image into the context, aligning an anchor within the | |
/// image to a point in the context. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the image. | |
/// | |
/// - Parameters: | |
/// - image: The ``ResolvedImage`` to draw. Get a resolved image from an | |
/// ``Image`` by calling ``resolve(_:)-898z6``. Alternatively, you can | |
/// call ``draw(_:at:anchor:)-7l217`` with an ``Image``, and that method | |
/// performs the resolution automatically. | |
/// - point: A point within the rectangle of the resolved image to anchor | |
/// to a point in the context. | |
/// - anchor: A ``UnitPoint`` within the context to align the image with. | |
/// The default is ``UnitPoint/center``. | |
public func draw(_ image: GraphicsContext.ResolvedImage, at point: CGPoint, anchor: UnitPoint = .center) | |
/// Draws an image into the context, using the specified rectangle | |
/// as a layout frame. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the image. | |
/// | |
/// - Parameters: | |
/// - image: The ``Image`` to draw. Before drawing, the method converts | |
/// the image to a ``ResolvedImage`` by calling ``resolve(_:)-898z6``. | |
/// - rect: The rectangle in the current user space to draw the image in. | |
/// - style: A fill style to use when rasterizing the image. | |
public func draw(_ image: Image, in rect: CGRect, style: FillStyle = FillStyle()) | |
/// Draws an image into the context, aligning an anchor within the image | |
/// to a point in the context. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the image. | |
/// | |
/// - Parameters: | |
/// - image: The ``Image`` to draw. Before drawing, the method converts | |
/// the image to a ``ResolvedImage`` by calling ``resolve(_:)-898z6``. | |
/// - point: A point within the rectangle of the resolved image to anchor | |
/// to a point in the context. | |
/// - anchor: A ``UnitPoint`` within the context to align the image with. | |
/// The default is ``UnitPoint/center``. | |
public func draw(_ image: Image, at point: CGPoint, anchor: UnitPoint = .center) | |
/// A text view resolved to a particular environment. | |
/// | |
/// You resolve a ``Text`` view in preparation for drawing it into a context, | |
/// either manually by calling ``resolve(_:)-4dx65`` or automatically | |
/// when calling ``draw(_:in:)-5opqf`` or ``draw(_:at:anchor:)-5dgmd``. | |
/// The resolved text view takes into account environment values like the | |
/// display resolution and current color scheme. | |
public struct ResolvedText { | |
/// The shading to fill uncolored text regions with. | |
/// | |
/// This value defaults to the ``GraphicsContext/Shading/foreground`` | |
/// shading. | |
public var shading: GraphicsContext.Shading | |
/// Measures the size of the resolved text for a given | |
/// area into which the text should be placed. | |
/// | |
/// - Parameter size: The area to place the ``Text`` view in. | |
public func measure(in size: CGSize) -> CGSize | |
/// Gets the distance from the first line's ascender to its baseline. | |
public func firstBaseline(in size: CGSize) -> CGFloat | |
/// Gets the distance from the first line's ascender to the last | |
/// line's baseline. | |
public func lastBaseline(in size: CGSize) -> CGFloat | |
} | |
/// Gest a version of a text view that's fixed with the current values of | |
/// the graphics context's environment. | |
/// | |
/// You can measure the resolved text by calling its | |
/// ``ResolvedText/measure(in:)`` method. | |
/// You can draw the resolved text with the context's | |
/// ``draw(_:in:)-69ad8`` or ``draw(_:at:anchor:)-6xr87`` method. | |
/// | |
/// - Parameter text: The ``Text`` view to resolve. | |
/// - Returns: A text view that's resolved into the current context's | |
/// environment, taking into account environment values like the | |
/// display resolution and current color scheme. | |
public func resolve(_ text: Text) -> GraphicsContext.ResolvedText | |
/// Draws resolved text into the context using the specified rectangle | |
/// as a layout frame. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the text. | |
/// | |
/// - Parameters: | |
/// - text: The ``ResolvedText`` to draw. Get resolved text from a | |
/// ``Text`` view by calling ``resolve(_:)-4dx65``. Alternatively, you | |
/// can call ``draw(_:in:)-5opqf`` with a ``Text`` view, and that | |
/// method performs the resolution automatically. | |
/// - rect: The rectangle in the current user space to draw the text in. | |
/// - shading: The shading to use when coloring the text. | |
public func draw(_ text: GraphicsContext.ResolvedText, in rect: CGRect) | |
/// Draws resolved text into the context, aligning an anchor within the | |
/// ideal size of the text to a point in the context. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the text. | |
/// | |
/// - Parameters: | |
/// - text: The ``ResolvedText`` to draw. Get resolved text from a | |
/// ``Text`` view by calling ``resolve(_:)-4dx65``. Alternatively, you | |
/// can call ``draw(_:at:anchor:)-5dgmd`` with a ``Text`` view, and that | |
/// method performs the resolution automatically. | |
/// - point: A point within the rectangle of the ideal size of the | |
/// resolved text to anchor to a point in the context. | |
/// - anchor: A ``UnitPoint`` within the context to align the text with. | |
/// The default is ``UnitPoint/center``. | |
public func draw(_ text: GraphicsContext.ResolvedText, at point: CGPoint, anchor: UnitPoint = .center) | |
/// Draws text into the context using the specified rectangle | |
/// as a layout frame. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the text. | |
/// | |
/// - Parameters: | |
/// - text: The ``Text`` view to draw. Before drawing, the method converts | |
/// the view to ``ResolvedText`` by calling ``resolve(_:)-4dx65``. | |
/// - rect: The rectangle in the current user space to draw the text in. | |
public func draw(_ text: Text, in rect: CGRect) | |
/// Draws text into the context, aligning an anchor within the ideal size | |
/// of the rendered text to a point in the context. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the text. | |
/// | |
/// - Parameters: | |
/// - text: The ``Text`` view to draw. Before drawing, the method converts | |
/// the view to ``ResolvedText`` by calling ``resolve(_:)-4dx65``. | |
/// - point: A point within the rectangle of the resolved text to anchor | |
/// to a point in the context. | |
/// - anchor: A ``UnitPoint`` within the context to align the text with. | |
/// The default is ``UnitPoint/center``. | |
public func draw(_ text: Text, at point: CGPoint, anchor: UnitPoint = .center) | |
/// A static sequence of drawing operations that may be drawn | |
/// multiple times, preserving their resolution independence. | |
/// | |
/// You resolve a child view in preparation for drawing it into a context | |
/// by calling ``resolveSymbol(id:)``. The resolved view takes into account | |
/// environment values like the display resolution and current color scheme. | |
public struct ResolvedSymbol { | |
/// The dimensions of the resolved symbol. | |
public var size: CGSize { get } | |
} | |
/// Gets the identified child view as a resolved symbol, if the view exists. | |
/// | |
/// - Parameter id: The value that you used to tag the view when you | |
/// define it in the `symbols` parameter of the ``Canvas`` initializer | |
/// ``Canvas/init(opaque:colorMode:rendersAsynchronously:renderer:symbols:)``. | |
/// - Returns: The resolved symbol, or `nil` if SwiftUI can't find a child | |
/// view with the given `id`. | |
public func resolveSymbol<ID>(id: ID) -> GraphicsContext.ResolvedSymbol? where ID : Hashable | |
/// Draws a resolved symbol into the context, using the specified rectangle | |
/// as a layout frame. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the symbol. | |
/// | |
/// - Parameters: | |
/// - symbol: The ``ResolvedSymbol`` to draw. Get a resolved symbol | |
/// by calling ``resolveSymbol(id:)`` with the identifier that you | |
/// use to tag the corresponding child view during ``Canvas`` | |
/// initialization. | |
/// - rect: The rectangle in the current user space to draw the symbol in. | |
public func draw(_ symbol: GraphicsContext.ResolvedSymbol, in rect: CGRect) | |
/// Draws a resolved symbol into the context, aligning an anchor within the | |
/// symbol to a point in the context. | |
/// | |
/// The current context state defines the full drawing operation. For | |
/// example, the current transformation and clip shapes affect how SwiftUI | |
/// draws the symbol. | |
/// | |
/// - Parameters: | |
/// - symbol: The ``ResolvedSymbol`` view to draw. Get a resolved symbol | |
/// by calling ``resolveSymbol(id:)`` with the identifier that you | |
/// use to tag the corresponding child view during ``Canvas`` | |
/// initialization. | |
/// - point: A point within the rectangle of the resolved symbol to anchor | |
/// to a point in the context. | |
/// - anchor: A ``UnitPoint`` within the context to align the symbol with. | |
/// The default is ``UnitPoint/center``. | |
public func draw(_ symbol: GraphicsContext.ResolvedSymbol, at point: CGPoint, anchor: UnitPoint = .center) | |
/// Provides a Core Graphics context that you can use as a proxy to draw | |
/// into this context. | |
/// | |
/// Use this method to use existing drawing code that relies on | |
/// Core Graphics primitives. | |
/// | |
/// - Parameter content: A closure that receives a | |
/// <doc://com.apple.documentation/documentation/CoreGraphics/CGContext> | |
/// that you use to perform drawing operations, just like you draw into a | |
/// ``GraphicsContext`` instance. Any filters, blend mode settings, clip | |
/// masks, and other state set before calling `withCGContext(content:)` | |
/// apply to drawing operations in the Core Graphics context as well. Any | |
/// state you set on the Core Graphics context is lost when the closure | |
/// returns. Accessing the Core Graphics context after the closure | |
/// returns produces undefined behavior. | |
public func withCGContext(content: (CGContext) throws -> Void) rethrows | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension GraphicsContext.BlendMode : Sendable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension GraphicsContext.ClipOptions : Sendable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension GraphicsContext.ShadowOptions : Sendable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension GraphicsContext.BlurOptions : Sendable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension GraphicsContext.FilterOptions : Sendable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension GraphicsContext.GradientOptions : Sendable { | |
} | |
/// A description of a single grid item, such as a row or a column. | |
/// | |
/// You use `GridItem` instances to configure the layout of items in | |
/// ``LazyHGrid`` and ``LazyVGrid`` views. Each grid item specifies layout | |
/// properties like spacing and alignment, which the grid view uses to size and | |
/// position all items in a given column or row. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct GridItem { | |
/// The size in the minor axis of one or more rows or columns in a grid | |
/// layout. | |
public enum Size { | |
/// A single item with the specified fixed size. | |
case fixed(CGFloat) | |
/// A single flexible item. | |
/// | |
/// The size of this item is the size of the grid with spacing and | |
/// inflexible items removed, divided by the number of flexible items, | |
/// clamped to the provided bounds. | |
case flexible(minimum: CGFloat = 10, maximum: CGFloat = .infinity) | |
/// Multiple items in the space of a single flexible item. | |
/// | |
/// This size case places one or more items into the space assigned to | |
/// a single `flexible` item, using the provided bounds and | |
/// spacing to decide exactly how many items fit. This approach prefers | |
/// to insert as many items of the `minimum` size as possible | |
/// but lets them increase to the `maximum` size. | |
case adaptive(minimum: CGFloat, maximum: CGFloat = .infinity) | |
} | |
/// The size of the item, which is the width of a column item or the | |
/// height of a row item. | |
public var size: GridItem.Size | |
/// The spacing to the next item. | |
/// | |
/// If this value is `nil`, the item uses a reasonable default for the | |
/// current platform. | |
public var spacing: CGFloat? | |
/// The alignment to use when placing each view. | |
/// | |
/// Use this property to anchor the view's relative position to the same | |
/// relative position in the view's assigned grid space. | |
public var alignment: Alignment? | |
/// Creates a grid item with the provided size, spacing, and alignment | |
/// properties. | |
/// | |
/// - Parameters: | |
/// - size: The size of the grid item. | |
/// - spacing: The spacing to use between this and the next item. | |
/// - alignment: The alignment to use for this grid item. | |
public init(_ size: GridItem.Size = .flexible(), spacing: CGFloat? = nil, alignment: Alignment? = nil) | |
} | |
/// A type that collects multiple instances of a content type --- like views, | |
/// scenes, or commands --- into a single unit. | |
/// | |
/// Use a group to collect multiple views into a single instance, without | |
/// affecting the layout of those views, like an ``SwiftUI/HStack``, | |
/// ``SwiftUI/VStack``, or ``SwiftUI/Section`` would. After creating a group, | |
/// any modifier you apply to the group affects all of that group's members. | |
/// For example, the following code applies the ``SwiftUI/Font/headline`` | |
/// font to three views in a group. | |
/// | |
/// Group { | |
/// Text("SwiftUI") | |
/// Text("Combine") | |
/// Text("Swift System") | |
/// } | |
/// .font(.headline) | |
/// | |
/// Because you create a group of views with a ``SwiftUI/ViewBuilder``, you can | |
/// use the group's initializer to produce different kinds of views from a | |
/// conditional, and then optionally apply modifiers to them. The following | |
/// example uses a `Group` to add a navigation bar title, | |
/// regardless of the type of view the conditional produces: | |
/// | |
/// Group { | |
/// if isLoggedIn { | |
/// WelcomeView() | |
/// } else { | |
/// LoginView() | |
/// } | |
/// } | |
/// .navigationBarTitle("Start") | |
/// | |
/// The modifier applies to all members of the group --- and not to the group | |
/// itself. For example, if you apply ``View/onAppear(perform:)`` to the above | |
/// group, it applies to all of the views produced by the `if isLoggedIn` | |
/// conditional, and it executes every time `isLoggedIn` changes. | |
/// | |
/// Because a group of views itself is a view, you can compose a group within | |
/// other view builders, including nesting within other groups. This allows you | |
/// to add large numbers of views to different view builder containers. The | |
/// following example uses a `Group` to collect 10 ``SwiftUI/Text`` instances, | |
/// meaning that the vertical stack's view builder returns only two views --- | |
/// the group, plus an additional ``SwiftUI/Text``: | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// Group { | |
/// Text("1") | |
/// Text("2") | |
/// Text("3") | |
/// Text("4") | |
/// Text("5") | |
/// Text("6") | |
/// Text("7") | |
/// Text("8") | |
/// Text("9") | |
/// Text("10") | |
/// } | |
/// Text("11") | |
/// } | |
/// } | |
/// | |
/// You can initialize groups with several types other than ``SwiftUI/View``, | |
/// such as ``SwiftUI/Scene`` and ``SwiftUI/ToolbarContent``. The closure you | |
/// provide to the group initializer uses the corresponding builder type | |
/// (``SwiftUI/SceneBuilder``, ``SwiftUI/ToolbarContentBuilder``, and so on), | |
/// and the capabilities of these builders vary between types. For example, | |
/// you can use groups to return large numbers of scenes or toolbar content | |
/// instances, but not to return different scenes or toolbar content based | |
/// on conditionals. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Group<Content> { | |
/// The type for the internal content of this `AccessibilityRotorContent`. | |
public typealias Body = Never | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Group : AccessibilityRotorContent where Content : AccessibilityRotorContent { | |
/// The internal content of this `AccessibilityRotorContent`. | |
public var body: Never { get } | |
/// Creates an instance that generates Rotor content by combining, in order, | |
/// all the Rotor content specified in the passed-in result builder. | |
/// | |
/// - Parameter content: The result builder that generates Rotor content for | |
/// the group. | |
public init(@AccessibilityRotorContentBuilder content: () -> Content) | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Group : ToolbarContent where Content : ToolbarContent { | |
/// Creates a group of toolbar content instances. | |
/// | |
/// - Parameter content: A ``SwiftUI/ToolbarContentBuilder`` that produces | |
/// the toolbar content instances to group. | |
public init(@ToolbarContentBuilder content: () -> Content) | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Group : CustomizableToolbarContent where Content : CustomizableToolbarContent { | |
/// Creates a group of customizable toolbar content instances. | |
/// | |
/// - Parameter content: A ``SwiftUI/ToolbarContentBuilder`` that produces | |
/// the customizable toolbar content instances to group. | |
public init(@ToolbarContentBuilder content: () -> Content) | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Group : Scene where Content : Scene { | |
/// Creates a group of scenes. | |
/// | |
/// - Parameter content: A ``SwiftUI/SceneBuilder`` that produces the scenes | |
/// to group. | |
@inlinable public init(@SceneBuilder content: () -> Content) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Group : View where Content : View { | |
/// Creates a group of views. | |
/// - Parameter content: A ``SwiftUI/ViewBuilder`` that produces the views | |
/// to group. | |
@inlinable public init(@ViewBuilder content: () -> Content) | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Group : Commands where Content : Commands { | |
/// Creates a group of commands. | |
/// | |
/// - Parameter content: A ``SwiftUI/CommandsBuilder`` that produces the | |
/// commands to group. | |
@inlinable public init(@CommandsBuilder content: () -> Content) | |
} | |
/// A stylized view, with an optional label, that visually collects a logical | |
/// grouping of content. | |
/// | |
/// Use a group box when you want to visually distinguish a portion of your | |
/// user interface with an optional title for the boxed content. | |
/// | |
/// The following example sets up a `GroupBox` with the label "End-User | |
/// Agreement", and a long `agreementText` string in a ``SwiftUI/Text`` view | |
/// wrapped by a ``SwiftUI/ScrollView``. The box also contains a | |
/// ``SwiftUI/Toggle`` for the user to interact with after reading the text. | |
/// | |
/// var body: some View { | |
/// GroupBox(label: | |
/// Label("End-User Agreement", systemImage: "building.columns") | |
/// ) { | |
/// ScrollView(.vertical, showsIndicators: true) { | |
/// Text(agreementText) | |
/// .font(.footnote) | |
/// } | |
/// .frame(height: 100) | |
/// Toggle(isOn: $userAgreed) { | |
/// Text("I agree to the above terms") | |
/// } | |
/// } | |
/// } | |
/// | |
/// ![An iOS status bar above a gray rounded rectangle region marking the bounds | |
/// of the group box. At the top of the region, the title End-User Agreement | |
/// in a large bold font with an icon of a building with columns. Below this, | |
/// a scroll view with six lines of text visible. At the bottom of the gray | |
/// group box region, a toggle switch with the label I agree to the above | |
/// terms.](SwiftUI-GroupBox-EULA.png) | |
/// | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct GroupBox<Label, Content> : View where Label : View, Content : View { | |
/// Creates a group box with the provided label and view content. | |
/// - Parameters: | |
/// - content: A ``SwiftUI/ViewBuilder`` that produces the content for the | |
/// group box. | |
/// - label: A ``SwiftUI/ViewBuilder` that produces a label for the group | |
/// box. | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension GroupBox where Label == GroupBoxStyleConfiguration.Label, Content == GroupBoxStyleConfiguration.Content { | |
/// Creates a group box based on a style configuration. | |
/// | |
/// Use this initializer within the ``GroupBoxStyle/makeBody(configuration:)`` | |
/// method of a ``GroupBoxStyle`` instance to create a styled group box, | |
/// with customizations, while preserving its existing style. | |
/// | |
/// The following example adds a pink border around the group box, | |
/// without overriding its current style: | |
/// | |
/// struct PinkBorderGroupBoxStyle: GroupBoxStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// GroupBox(configuration) | |
/// .border(Color.pink) | |
/// } | |
/// } | |
/// - Parameter configuration: The properties of the group box instance being created. | |
public init(_ configuration: GroupBoxStyleConfiguration) | |
} | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension GroupBox where Label == EmptyView { | |
/// Creates an unlabeled group box with the provided view content. | |
/// - Parameters: | |
/// - content: A ``SwiftUI/ViewBuilder`` that produces the content for | |
/// the group box. | |
public init(@ViewBuilder content: () -> Content) | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension GroupBox where Label == Text { | |
/// Creates a group box with the provided view content and title. | |
/// - Parameters: | |
/// - titleKey: The key for the group box's title, which describes the | |
/// content of the group box. | |
/// - content: A ``SwiftUI/ViewBuilder`` that produces the content for the | |
/// group box. | |
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content) | |
/// Creates a group box with the provided view content. | |
/// - Parameters: | |
/// - title: A string that describes the content of the group box. | |
/// - content: A ``SwiftUI/ViewBuilder`` that produces the content for the | |
/// group box. | |
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where S : StringProtocol | |
} | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension GroupBox { | |
@available(iOS, deprecated: 100000.0, renamed: "GroupBox(content:label:)") | |
@available(macOS, deprecated: 100000.0, renamed: "GroupBox(content:label:)") | |
public init(label: Label, @ViewBuilder content: () -> Content) | |
} | |
/// A type that specifies the appearance and interaction of all group boxes | |
/// within a view hierarchy. | |
/// | |
/// To configure the current `GroupBoxStyle` for a view hierarchy, use the | |
/// ``View/groupBoxStyle(_:)`` modifier. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public protocol GroupBoxStyle { | |
/// A view that represents the body of a group box. | |
associatedtype Body : View | |
/// Creates a view representing the body of a group box. | |
/// | |
/// SwiftUI calls this method for each instance of ``SwiftUI/GroupBox`` | |
/// created within a view hierarchy where this style is the current | |
/// group box style. | |
/// | |
/// - Parameter configuration: The properties of the group box instance being | |
/// created. | |
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body | |
/// The properties of a group box instance. | |
typealias Configuration = GroupBoxStyleConfiguration | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension GroupBoxStyle where Self == DefaultGroupBoxStyle { | |
/// The default style for group box views. | |
public static var automatic: DefaultGroupBoxStyle { get } | |
} | |
/// The properties of a group box instance. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct GroupBoxStyleConfiguration { | |
/// A type-erased label of a group box. | |
public struct Label : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A type-erased content of a group box. | |
public struct Content : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A view that provides the title of the group box. | |
public let label: GroupBoxStyleConfiguration.Label | |
/// A view that represents the content of the group box. | |
public let content: GroupBoxStyleConfiguration.Content | |
} | |
/// The list style that describes the behavior and appearance of a grouped list. | |
/// | |
/// Do not use this type directly. Instead, use ``ListStyle/grouped``. | |
@available(iOS 13.0, tvOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct GroupedListStyle : ListStyle { | |
/// Creates a grouped list style. | |
public init() | |
} | |
/// A view that arranges its children in a horizontal line. | |
/// | |
/// Unlike ``LazyHStack``, which only renders the views when your app needs to | |
/// display them onscreen, an `HStack` renders the views all at once, regardless | |
/// of whether they are on- or offscreen. Use the regular `HStack` when you have | |
/// a small number of child views or don't want the delayed rendering behavior | |
/// of the "lazy" version. | |
/// | |
/// The following example shows a simple horizontal stack of five text views: | |
/// | |
/// var body: some View { | |
/// HStack( | |
/// alignment: .top, | |
/// spacing: 10 | |
/// ) { | |
/// ForEach( | |
/// 1...5, | |
/// id: \.self | |
/// ) { | |
/// Text("Item \($0)") | |
/// } | |
/// } | |
/// } | |
/// ![Five text views, named Item 1 through Item 5, arranged in a | |
/// horizontal row.](SwiftUI-HStack-simple.png) | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct HStack<Content> : View where Content : View { | |
/// Creates a horizontal stack with the given spacing and vertical alignment. | |
/// | |
/// - Parameters: | |
/// - alignment: The guide for aligning the subviews in this stack. This | |
/// guide has the same vertical screen coordinate for every child view. | |
/// - spacing: The distance between adjacent subviews, or `nil` if you | |
/// want the stack to choose a default distance for each pair of | |
/// subviews. | |
/// - content: A view builder that creates the content of this stack. | |
@inlinable public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, @ViewBuilder content: () -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A shape style that maps to one of the numbered content styles. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
@frozen public struct HierarchicalShapeStyle : ShapeStyle { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension HierarchicalShapeStyle : Sendable { | |
} | |
/// An alignment position along the horizontal axis. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct HorizontalAlignment : Equatable { | |
/// Creates an instance with the given identifier. | |
/// | |
/// Each instance needs a unique identifier. | |
/// | |
/// - Parameter id: An identifier that uniquely identifies the horizontal | |
/// alignment. | |
public init(_ id: AlignmentID.Type) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: HorizontalAlignment, b: HorizontalAlignment) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension HorizontalAlignment { | |
/// A guide marking the leading edge of the view. | |
public static let leading: HorizontalAlignment | |
/// A guide marking the horizontal center of the view. | |
public static let center: HorizontalAlignment | |
/// A guide marking the trailing edge of the view. | |
public static let trailing: HorizontalAlignment | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension HorizontalAlignment : Sendable { | |
} | |
/// An edge on the horizontal axis. | |
/// | |
/// Use a horizontal edge for tasks like setting a swipe action with the | |
/// ``View/swipeActions(edge:allowsFullSwipe:content:)`` | |
/// view modifier. The positions of the leading and trailing edges | |
/// depend on the locale chosen by the user. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
@frozen public enum HorizontalEdge : Int8, CaseIterable, Codable { | |
/// The leading edge. | |
case leading | |
/// The trailing edge. | |
case trailing | |
/// An efficient set of `HorizontalEdge`s. | |
@frozen public struct Set : OptionSet { | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = HorizontalEdge.Set | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: Int8 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
public init(rawValue: Int8) | |
/// A set containing only the leading horizontal edge. | |
public static let leading: HorizontalEdge.Set | |
/// A set containing only the trailing horizontal edge. | |
public static let trailing: HorizontalEdge.Set | |
/// A set containing the leading and trailing horizontal edges. | |
public static let all: HorizontalEdge.Set | |
/// Creates an instance containing just `e`. | |
public init(_ edge: HorizontalEdge) | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = HorizontalEdge.Set.Element | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int8 | |
} | |
/// Creates a new instance with the specified raw value. | |
/// | |
/// If there is no value of the type that corresponds with the specified raw | |
/// value, this initializer returns `nil`. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// print(PaperSize(rawValue: "Legal")) | |
/// // Prints "Optional("PaperSize.Legal")" | |
/// | |
/// print(PaperSize(rawValue: "Tabloid")) | |
/// // Prints "nil" | |
/// | |
/// - Parameter rawValue: The raw value to use for the new instance. | |
public init?(rawValue: Int8) | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [HorizontalEdge] | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int8 | |
/// A collection of all values of this type. | |
public static var allCases: [HorizontalEdge] { get } | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public var rawValue: Int8 { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension HorizontalEdge : Equatable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension HorizontalEdge : Hashable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension HorizontalEdge : RawRepresentable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension HorizontalEdge : Sendable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension HorizontalEdge.Set : Sendable { | |
} | |
/// An effect applied when the pointer hovers over a view. | |
@available(iOS 13.4, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct HoverEffect { | |
/// An effect that attempts to determine the effect automatically. | |
/// This is the default effect. | |
public static let automatic: HoverEffect | |
/// An effect that morphs the pointer into a platter behind the view | |
/// and shows a light source indicating position. | |
public static let highlight: HoverEffect | |
/// An effect that slides the pointer under the view and disappears as the | |
/// view scales up and gains a shadow. | |
public static let lift: HoverEffect | |
} | |
/// A label style that only displays the icon of the label. | |
/// | |
/// Do not use this type directly. Instead, use ``LabelStyle/iconOnly``. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct IconOnlyLabelStyle : LabelStyle { | |
/// Creates an icon-only label style. | |
public init() | |
/// Creates a view that represents the body of a label. | |
/// | |
/// The system calls this method for each ``Label`` instance in a view | |
/// hierarchy where this style is the current label style. | |
/// | |
/// - Parameter configuration: The properties of the label. | |
public func makeBody(configuration: IconOnlyLabelStyle.Configuration) -> some View | |
/// A view that represents the body of a label. | |
public typealias Body = some View | |
} | |
/// A view that displays an image. | |
/// | |
/// Use an `Image` instance when you want to add images to your SwiftUI app. | |
/// You can create images from many sources: | |
/// | |
/// * Image files in your app's asset library or bundle. Supported types include | |
/// PNG, JPEG, HEIC, and more. | |
/// * Instances of platform-specific image types, like | |
/// <doc://com.apple.documentation/documentation/UIKit/UIImage> and | |
/// <doc://com.apple.documentation/documentation/AppKit/NSImage>. | |
/// * A bitmap stored in a Core Graphics | |
/// <doc://com.apple.documentation/documentation/coregraphics/cgimage> | |
/// instance. | |
/// * System graphics from the SF Symbols set. | |
/// | |
/// The following example shows how to load an image from the app's asset | |
/// library or bundle and scale it to fit within its container: | |
/// | |
/// Image("Landscape_4") | |
/// .resizable() | |
/// .aspectRatio(contentMode: .fit) | |
/// Text("Water wheel") | |
/// | |
/// ![An image of a water wheel and its adjoining building, resized to fit the | |
/// width of an iPhone display. The words Water wheel appear under this | |
/// image.](SwiftUI-Image-waterWheel-resize.png) | |
/// | |
/// You can use methods on the `Image` type as well as | |
/// standard view modifiers to adjust the size of the image to fit your app's | |
/// interface. Here, the `Image` type's | |
/// ``Image/resizable(capInsets:resizingMode:)`` method scales the image to fit | |
/// the current view. Then, the | |
/// ``View/aspectRatio(_:contentMode:)-771ow`` view modifier adjusts | |
/// this resizing behavior to maintain the image's original aspect ratio, rather | |
/// than scaling the x- and y-axes independently to fill all four sides of the | |
/// view. The article | |
/// <doc:Fitting-Images-into-Available-Space> shows how to apply scaling, | |
/// clipping, and tiling to `Image` instances of different sizes. | |
/// | |
/// An `Image` is a late-binding token; the system resolves its actual value | |
/// only when it's about to use the image in an environment. | |
/// | |
/// ### Making Images Accessible | |
/// | |
/// To use an image as a control, use one of the initializers that takes a | |
/// `label` parameter. This allows the system's accessibility frameworks to use | |
/// the label as the name of the control for users who use features like | |
/// VoiceOver. For images that are only present for aesthetic reasons, use an | |
/// initializer with the `decorative` parameter; the accessibility systems | |
/// ignore these images. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Image : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (lhs: Image, rhs: Image) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// Creates a labeled image that you can use as content for controls. | |
/// | |
/// - Parameters: | |
/// - name: The name of the image resource to lookup, as well as the | |
/// localization key with which to label the image. | |
/// - bundle: The bundle to search for the image resource and localization | |
/// content. If `nil`, SwiftUI uses the main `Bundle`. Defaults to `nil`. | |
public init(_ name: String, bundle: Bundle? = nil) | |
/// Creates a labeled image that you can use as content for controls, with | |
/// the specified label. | |
/// | |
/// - Parameters: | |
/// - name: The name of the image resource to lookup | |
/// - bundle: The bundle to search for the image resource. If `nil`, | |
/// SwiftUI uses the main `Bundle`. Defaults to `nil`. | |
/// - label: The label associated with the image. SwiftUI uses the label | |
/// for accessibility. | |
public init(_ name: String, bundle: Bundle? = nil, label: Text) | |
/// Creates an unlabeled, decorative image. | |
/// | |
/// SwiftUI ignores this image for accessibility purposes. | |
/// | |
/// - Parameters: | |
/// - name: The name of the image resource to lookup | |
/// - bundle: The bundle to search for the image resource. If `nil`, | |
/// SwiftUI uses the main `Bundle`. Defaults to `nil`. | |
public init(decorative name: String, bundle: Bundle? = nil) | |
/// Creates a system symbol image. | |
/// | |
/// This initializer creates an image using a system-provided symbol. To | |
/// create a custom symbol image from your app's asset catalog, use | |
/// ``Image/init(_:bundle:)`` instead. | |
/// | |
/// - Parameters: | |
/// - systemName: The name of the system symbol image. | |
/// Use the SF Symbols app to look up the names of system symbol images. | |
@available(macOS 11.0, *) | |
public init(systemName: String) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// Indicates whether SwiftUI renders an image as-is, or | |
/// by using a different mode. | |
/// | |
/// The ``TemplateRenderingMode`` enumeration has two cases: | |
/// ``TemplateRenderingMode/original`` and ``TemplateRenderingMode/template``. | |
/// The original mode renders pixels as they appear in the original source | |
/// image. Template mode renders all nontransparent pixels as the | |
/// foreground color, which you can use for purposes like creating image | |
/// masks. | |
/// | |
/// The following example shows both rendering modes, as applied to an icon | |
/// image of a green circle with darker green border: | |
/// | |
/// Image("dot_green") | |
/// .renderingMode(.original) | |
/// Image("dot_green") | |
/// .renderingMode(.template) | |
/// | |
/// ![Two identically-sized circle images. The circle on top is green | |
/// with a darker green border. The circle at the bottom is a solid color, | |
/// either white on a black background, or black on a white background, | |
/// depending on the system's current dark mode | |
/// setting.](SwiftUI-Image-TemplateRenderingMode-dots.png) | |
/// | |
/// You also use `renderingMode` to produce multicolored system graphics | |
/// from the SF Symbols set. Use the ``TemplateRenderingMode/original`` | |
/// mode to apply a foreground color to all parts of the symbol except | |
/// those that have a distinct color in the graphic. The following | |
/// example shows three uses of the `person.crop.circle.badge.plus` symbol | |
/// to achieve different effects: | |
/// | |
/// * A default appearance with no foreground color or template rendering | |
/// mode specified. The symbol appears all black in light mode, and all | |
/// white in Dark Mode. | |
/// * The multicolor behavior achieved by using `original` template | |
/// rendering mode, along with a blue foreground color. This mode causes the | |
/// graphic to override the foreground color for distinctive parts of the | |
/// image, in this case the plus icon. | |
/// * A single-color template behavior achieved by using `template` | |
/// rendering mode with a blue foreground color. This mode applies the | |
/// foreground color to the entire image, regardless of the user's Appearance preferences. | |
/// | |
///```swift | |
///HStack { | |
/// Image(systemName: "person.crop.circle.badge.plus") | |
/// Image(systemName: "person.crop.circle.badge.plus") | |
/// .renderingMode(.original) | |
/// .foregroundColor(.blue) | |
/// Image(systemName: "person.crop.circle.badge.plus") | |
/// .renderingMode(.template) | |
/// .foregroundColor(.blue) | |
///} | |
///.font(.largeTitle) | |
///``` | |
/// | |
/// ![A horizontal layout of three versions of the same symbol: a person | |
/// icon in a circle with a plus icon overlaid at the bottom left. Each | |
/// applies a diffent set of colors based on its rendering mode, as | |
/// described in the preceding | |
/// list.](SwiftUI-Image-TemplateRenderingMode-sfsymbols.png) | |
/// | |
/// Use the SF Symbols app to find system images that offer the multicolor | |
/// feature. Keep in mind that some multicolor symbols use both the | |
/// foreground and accent colors. | |
/// | |
/// - Parameter renderingMode: The mode SwiftUI uses to render images. | |
/// - Returns: A modified ``Image``. | |
public func renderingMode(_ renderingMode: Image.TemplateRenderingMode?) -> Image | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// The orientation of an image. | |
/// | |
/// Many image formats such as JPEG include orientation metadata in the | |
/// image data. In other cases, you can specify image orientation | |
/// in code. Properly specifying orientation is often important both for | |
/// displaying the image and for certain kinds of image processing. | |
/// | |
/// In SwiftUI, you provide an orientation value when initializing an | |
/// ``Image`` from an existing | |
/// <doc://com.apple.documentation/documentation/coregraphics/cgimage>. | |
@frozen public enum Orientation : UInt8, CaseIterable, Hashable { | |
/// A value that indicates the original pixel data matches the image's | |
/// intended display orientation. | |
case up | |
/// A value that indicates a horizontal flip of the image from the | |
/// orientation of its original pixel data. | |
case upMirrored | |
/// A value that indicates a 180° rotation of the image from the | |
/// orientation of its original pixel data. | |
case down | |
/// A value that indicates a vertical flip of the image from the | |
/// orientation of its original pixel data. | |
case downMirrored | |
/// A value that indicates a 90° counterclockwise rotation from the | |
/// orientation of its original pixel data. | |
case left | |
/// A value that indicates a 90° clockwise rotation and horizontal | |
/// flip of the image from the orientation of its original pixel | |
/// data. | |
case leftMirrored | |
/// A value that indicates a 90° clockwise rotation of the image from | |
/// the orientation of its original pixel data. | |
case right | |
/// A value that indicates a 90° counterclockwise rotation and | |
/// horizontal flip from the orientation of its original pixel data. | |
case rightMirrored | |
/// Creates a new instance with the specified raw value. | |
/// | |
/// If there is no value of the type that corresponds with the specified raw | |
/// value, this initializer returns `nil`. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// print(PaperSize(rawValue: "Legal")) | |
/// // Prints "Optional("PaperSize.Legal")" | |
/// | |
/// print(PaperSize(rawValue: "Tabloid")) | |
/// // Prints "nil" | |
/// | |
/// - Parameter rawValue: The raw value to use for the new instance. | |
public init?(rawValue: UInt8) | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [Image.Orientation] | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt8 | |
/// A collection of all values of this type. | |
public static var allCases: [Image.Orientation] { get } | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public var rawValue: UInt8 { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// A type that indicates how SwiftUI renders images. | |
public enum TemplateRenderingMode { | |
/// A mode that renders all non-transparent pixels as the foreground | |
/// color. | |
case template | |
/// A mode that renders pixels of bitmap images as-is. | |
/// | |
/// For system images created from the SF Symbol set, multicolor symbols | |
/// respect the current foreground and accent colors. | |
case original | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Image.TemplateRenderingMode, b: Image.TemplateRenderingMode) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
/// A scale to apply to vector images relative to text. | |
/// | |
/// Use this type with the ``View/imageScale(_:)`` modifier, or the | |
/// ``EnvironmentValues/imageScale`` environment key, to set the image scale. | |
/// | |
/// The following example shows the three `Scale` values as applied to | |
/// a system symbol image, each set against a text view: | |
/// | |
/// HStack { Image(systemName: "swift").imageScale(.small); Text("Small") } | |
/// HStack { Image(systemName: "swift").imageScale(.medium); Text("Medium") } | |
/// HStack { Image(systemName: "swift").imageScale(.large); Text("Large") } | |
/// | |
/// ![Vertically arranged text views that read Small, Medium, and | |
/// Large. On the left of each view is a system image that uses the Swift symbol. | |
/// The image next to the Small text is slightly smaller than the text. | |
/// The image next to the Medium text matches the size of the text. The | |
/// image next to the Large text is larger than the | |
/// text.](SwiftUI-EnvironmentAdditions-Image-scale.png) | |
/// | |
@available(macOS 11.0, *) | |
public enum Scale { | |
/// A scale that produces small images. | |
case small | |
/// A scale that produces medium-sized images. | |
case medium | |
/// A scale that produces large images. | |
case large | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Image.Scale, b: Image.Scale) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// The level of quality for rendering an image that requires interpolation, | |
/// such as a scaled image. | |
/// | |
/// The ``Image/interpolation(_:)`` modifier specifies the interpolation | |
/// behavior when using the ``Image/resizable(capInsets:resizingMode:)`` | |
/// modifier on an ``Image``. Use this behavior to prioritize rendering | |
/// performance or image quality. | |
public enum Interpolation { | |
/// A value that indicates SwiftUI doesn't interpolate image data. | |
case none | |
/// A value that indicates a low level of interpolation quality, which may | |
/// speed up image rendering. | |
case low | |
/// A value that indicates a medium level of interpolation quality, | |
/// between the low- and high-quality values. | |
case medium | |
/// A value that indicates a high level of interpolation quality, which | |
/// may slow down image rendering. | |
case high | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Image.Interpolation, b: Image.Interpolation) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// Specifies the current level of quality for rendering an | |
/// image that requires interpolation. | |
/// | |
/// See the article <doc:Fitting-Images-into-Available-Space> for examples | |
/// of using `interpolation(_:)` when scaling an ``Image``. | |
/// - Parameter interpolation: The quality level, expressed as a value of | |
/// the `Interpolation` type, that SwiftUI applies when interpolating | |
/// an image. | |
/// - Returns: An image with the given interpolation value set. | |
public func interpolation(_ interpolation: Image.Interpolation) -> Image | |
/// Specifies whether SwiftUI applies antialiasing when rendering | |
/// the image. | |
/// - Parameter isAntialiased: A Boolean value that specifies whether to | |
/// allow antialiasing. Pass `true` to allow antialising, `false` otherwise. | |
/// - Returns: An image with the antialiasing behavior set. | |
public func antialiased(_ isAntialiased: Bool) -> Image | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Image { | |
/// Sets the rendering mode for symbol images within this view. | |
/// | |
/// - Parameter mode: The symbol rendering mode to use. | |
/// | |
/// - Returns: A view that uses the rendering mode you supply. | |
public func symbolRenderingMode(_ mode: SymbolRenderingMode?) -> Image | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// Creates a labeled image based on a Core Graphics image instance, usable | |
/// as content for controls. | |
/// | |
/// - Parameters: | |
/// - cgImage: The base graphical image. | |
/// - scale: The scale factor for the image, | |
/// with a value like `1.0`, `2.0`, or `3.0`. | |
/// - orientation: The orientation of the image. The default is | |
/// ``Image/Orientation/up``. | |
/// - label: The label associated with the image. SwiftUI uses the label | |
/// for accessibility. | |
public init(_ cgImage: CGImage, scale: CGFloat, orientation: Image.Orientation = .up, label: Text) | |
/// Creates an unlabeled, decorative image based on a Core Graphics image | |
/// instance. | |
/// | |
/// SwiftUI ignores this image for accessibility purposes. | |
/// | |
/// - Parameters: | |
/// - cgImage: The base graphical image. | |
/// - scale: The scale factor for the image, | |
/// with a value like `1.0`, `2.0`, or `3.0`. | |
/// - orientation: The orientation of the image. The default is | |
/// ``Image/Orientation/up``. | |
public init(decorative cgImage: CGImage, scale: CGFloat, orientation: Image.Orientation = .up) | |
} | |
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
@available(macOS, unavailable) | |
extension Image { | |
/// Creates a SwiftUI image from a UIKit image instance. | |
/// - Parameter uiImage: The UIKit image to wrap with a SwiftUI ``Image`` | |
/// instance. | |
public init(uiImage: UIImage) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image { | |
/// The modes that SwiftUI uses to resize an image to fit within its containing view. | |
public enum ResizingMode { | |
/// A mode to repeat the image at its original size, as many times as | |
/// necessary to fill the available space. | |
case tile | |
/// A mode to enlarge or reduce the size of an image so that it fills the available space. | |
case stretch | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Image.ResizingMode, b: Image.ResizingMode) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
/// Sets the mode by which SwiftUI resizes an image to fit its space. | |
/// - Parameters: | |
/// - capInsets: Inset values that indicate a portion of the image that | |
/// SwiftUI doesn't resize. | |
/// - resizingMode: The mode by which SwiftUI resizes the image. | |
/// - Returns: An image, with the new resizing behavior set. | |
public func resizable(capInsets: EdgeInsets = EdgeInsets(), resizingMode: Image.ResizingMode = .stretch) -> Image | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.Orientation : RawRepresentable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.Orientation : Sendable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.TemplateRenderingMode : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.TemplateRenderingMode : Hashable { | |
} | |
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 11.0, *) | |
extension Image.Scale : Equatable { | |
} | |
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 11.0, *) | |
extension Image.Scale : Hashable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.Interpolation : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.Interpolation : Hashable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.ResizingMode : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Image.ResizingMode : Hashable { | |
} | |
/// A shape style that fills a shape by repeating a region of an image. | |
/// | |
/// Do not use this type directly. Use ``ShapeStyle/image(_:sourceRect:scale:)`` | |
/// instead. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct ImagePaint : ShapeStyle { | |
/// The image to be drawn. | |
public var image: Image | |
/// A unit-space rectangle defining how much of the source image to draw. | |
/// | |
/// The results are undefined if this rectangle selects areas outside the | |
/// `[0, 1]` range in either axis. | |
public var sourceRect: CGRect | |
/// A scale factor applied to the image while being drawn. | |
public var scale: CGFloat | |
/// Creates a shape-filling shape style. | |
/// | |
/// - Parameters: | |
/// - image: The image to be drawn. | |
/// - sourceRect: A unit-space rectangle defining how much of the source | |
/// image to draw. The results are undefined if `sourceRect` selects | |
/// areas outside the `[0, 1]` range in either axis. | |
/// - scale: A scale factor applied to the image during rendering. | |
public init(image: Image, sourceRect: CGRect = CGRect(x: 0, y: 0, width: 1, height: 1), scale: CGFloat = 1) | |
} | |
/// Defines the implementation of all `IndexView` instances within a view | |
/// hierarchy. | |
/// | |
/// To configure the current `IndexViewStyle` for a view hierarchy, use the | |
/// `.indexViewStyle()` modifier. | |
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *) | |
@available(macOS, unavailable) | |
public protocol IndexViewStyle { | |
} | |
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *) | |
@available(macOS, unavailable) | |
extension IndexViewStyle where Self == PageIndexViewStyle { | |
/// An index view style that places a page index view over its content. | |
public static var page: PageIndexViewStyle { get } | |
/// An index view style that places a page index view over its content. | |
/// | |
/// - Parameter backgroundDisplayMode: The display mode of the background of | |
/// any page index views receiving this style | |
public static func page(backgroundDisplayMode: PageIndexViewStyle.BackgroundDisplayMode) -> PageIndexViewStyle | |
} | |
/// A `PickerStyle` where each option is displayed inline with other views in | |
/// the current container. | |
/// | |
/// Do not use this type directly. Instead, use ``PickerStyle/inline``. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct InlinePickerStyle : PickerStyle { | |
/// Creates an inline picker style. | |
public init() | |
} | |
/// The list style that describes the behavior and appearance of an inset | |
/// grouped list. | |
/// | |
/// Do not use this type directly. Instead, use ``ListStyle/insetGrouped``. | |
@available(iOS 14.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct InsetGroupedListStyle : ListStyle { | |
/// Creates an inset grouped list style. | |
public init() | |
} | |
/// The list style that describes the behavior and appearance of an inset list. | |
/// | |
/// Do not use this type directly. Instead, use ``ListStyle/inset``. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct InsetListStyle : ListStyle { | |
/// Creates an inset list style. | |
public init() | |
} | |
/// A shape type that is able to inset itself to produce another shape. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol InsettableShape : Shape { | |
/// The type of the inset shape. | |
associatedtype InsetShape : InsettableShape | |
/// Returns `self` inset by `amount`. | |
func inset(by amount: CGFloat) -> Self.InsetShape | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension InsettableShape { | |
/// Returns a view that is the result of insetting `self` by | |
/// `style.lineWidth / 2`, stroking the resulting shape with | |
/// `style`, and then filling with `content`. | |
@inlinable public func strokeBorder<S>(_ content: S, style: StrokeStyle, antialiased: Bool = true) -> some View where S : ShapeStyle | |
/// Returns a view that is the result of insetting `self` by | |
/// `style.lineWidth / 2`, stroking the resulting shape with | |
/// `style`, and then filling with the foreground color. | |
@inlinable public func strokeBorder(style: StrokeStyle, antialiased: Bool = true) -> some View | |
/// Returns a view that is the result of filling the `width`-sized | |
/// border (aka inner stroke) of `self` with `content`. This is | |
/// equivalent to insetting `self` by `width / 2` and stroking the | |
/// resulting shape with `width` as the line-width. | |
@inlinable public func strokeBorder<S>(_ content: S, lineWidth: CGFloat = 1, antialiased: Bool = true) -> some View where S : ShapeStyle | |
/// Returns a view that is the result of filling the `width`-sized | |
/// border (aka inner stroke) of `self` with the foreground color. | |
/// This is equivalent to insetting `self` by `width / 2` and | |
/// stroking the resulting shape with `width` as the line-width. | |
@inlinable public func strokeBorder(lineWidth: CGFloat = 1, antialiased: Bool = true) -> some View | |
} | |
/// The orientation of the interface from the user's perspective. | |
/// | |
/// By default, device previews appear right side up, using orientation | |
/// ``InterfaceOrientation/portrait``. You can change the orientation | |
/// with a call to the ``View/previewInterfaceOrientation(_:)`` modifier: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// .previewInterfaceOrientation(.landscapeRight) | |
/// } | |
/// } | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct InterfaceOrientation : CaseIterable, Identifiable, Equatable { | |
/// A collection of all values of this type. | |
public static var allCases: [InterfaceOrientation] { get } | |
/// The stable identity of the entity associated with this instance. | |
public var id: String { get } | |
/// The device is in portrait mode, with the top of the device on top. | |
public static let portrait: InterfaceOrientation | |
/// The device is in portrait mode, but is upside down. | |
public static let portraitUpsideDown: InterfaceOrientation | |
/// The device is in landscape mode, with the top of the device on the left. | |
public static let landscapeLeft: InterfaceOrientation | |
/// The device is in landscape mode, with the top of the device on the right. | |
public static let landscapeRight: InterfaceOrientation | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: InterfaceOrientation, b: InterfaceOrientation) -> Bool | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [InterfaceOrientation] | |
/// A type representing the stable identity of the entity associated with | |
/// an instance. | |
public typealias ID = String | |
} | |
/// Key equivalents consist of a letter, punctuation, or function key that can | |
/// be combined with an optional set of modifier keys to specify a keyboard | |
/// shortcut. | |
/// | |
/// Key equivalents are used to establish keyboard shortcuts to app | |
/// functionality. Any key can be used as a key equivalent as long as pressing | |
/// it produces a single character value. Key equivalents are typically | |
/// initialized using a single-character string literal, with constants for | |
/// unprintable or hard-to-type values. | |
/// | |
/// The modifier keys necessary to type a key equivalent are factored in to the | |
/// resulting keyboard shortcut. That is, a key equivalent whose raw value is | |
/// the capitalized string "A" corresponds with the keyboard shortcut | |
/// Command-Shift-A. The exact mapping may depend on the keyboard layout—for | |
/// example, a key equivalent with the character value "}" produces a shortcut | |
/// equivalent to Command-Shift-] on ANSI keyboards, but would produce a | |
/// different shortcut for keyboard layouts where punctuation characters are in | |
/// different locations. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct KeyEquivalent { | |
/// Up Arrow (U+F700) | |
public static let upArrow: KeyEquivalent | |
/// Down Arrow (U+F701) | |
public static let downArrow: KeyEquivalent | |
/// Left Arrow (U+F702) | |
public static let leftArrow: KeyEquivalent | |
/// Right Arrow (U+F703) | |
public static let rightArrow: KeyEquivalent | |
/// Escape (U+001B) | |
public static let escape: KeyEquivalent | |
/// Delete (U+0008) | |
public static let delete: KeyEquivalent | |
/// Delete Forward (U+F728) | |
public static let deleteForward: KeyEquivalent | |
/// Home (U+F729) | |
public static let home: KeyEquivalent | |
/// End (U+F72B) | |
public static let end: KeyEquivalent | |
/// Page Up (U+F72C) | |
public static let pageUp: KeyEquivalent | |
/// Page Down (U+F72D) | |
public static let pageDown: KeyEquivalent | |
/// Clear (U+F739) | |
public static let clear: KeyEquivalent | |
/// Tab (U+0009) | |
public static let tab: KeyEquivalent | |
/// Space (U+0020) | |
public static let space: KeyEquivalent | |
/// Return (U+000D) | |
public static let `return`: KeyEquivalent | |
/// The character value that the key equivalent represents. | |
public var character: Character | |
/// Creates a new key equivalent from the given character value. | |
public init(_ character: Character) | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension KeyEquivalent : ExpressibleByExtendedGraphemeClusterLiteral { | |
/// Creates an instance initialized to the given value. | |
/// | |
/// - Parameter value: The value of the new instance. | |
public init(extendedGraphemeClusterLiteral: Character) | |
/// A type that represents an extended grapheme cluster literal. | |
/// | |
/// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`, | |
/// `String`, and `StaticString`. | |
public typealias ExtendedGraphemeClusterLiteralType = Character | |
/// A type that represents a Unicode scalar literal. | |
/// | |
/// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`, | |
/// `Character`, `String`, and `StaticString`. | |
public typealias UnicodeScalarLiteralType = Character | |
} | |
/// Keyboard shortcuts describe combinations of keys on a keyboard that the user | |
/// can press in order to activate a button or toggle. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct KeyboardShortcut { | |
/// Options for how a keyboard shortcut participates in automatic localization. | |
/// | |
/// A shortcut's `key` that is defined on an US-English keyboard | |
/// layout might not be reachable on international layouts. | |
/// For example the shortcut `⌘[` works well for the US layout but is | |
/// hard to reach for German users. | |
/// On the German keyboard layout, pressing `⌥5` will produce | |
/// `[`, which causes the shortcut to become `⌥⌘5`. | |
/// If configured, which is the default behavior, automatic shortcut | |
/// remapping will convert it to `⌘Ö`. | |
/// | |
/// In addition to that, some keyboard shortcuts carry information | |
/// about directionality. | |
/// Right-aligning a block of text or seeking forward in context of music | |
/// playback are such examples. These kinds of shortcuts benefit from the option | |
/// ``KeyboardShortcut/Localization-swift.struct/withoutMirroring`` | |
/// to tell the system that they won't be flipped when running in a | |
/// right-to-left context. | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct Localization { | |
/// Remap shortcuts to their international counterparts, mirrored for | |
/// right-to-left usage if appropriate. | |
/// | |
/// This is the default configuration. | |
public static let automatic: KeyboardShortcut.Localization | |
/// Don't mirror shortcuts. | |
/// | |
/// Use this for shortcuts that always have a specific directionality, like | |
/// aligning something on the right. | |
/// | |
/// Don't use this option for navigational shortcuts like "Go Back" because navigation | |
/// is flipped in right-to-left contexts. | |
public static let withoutMirroring: KeyboardShortcut.Localization | |
/// Don't use automatic shortcut remapping. | |
/// | |
/// When you use this mode, you have to take care of international use-cases separately. | |
public static let custom: KeyboardShortcut.Localization | |
} | |
/// The standard keyboard shortcut for the default button, consisting of | |
/// the Return (↩) key and no modifiers. | |
/// | |
/// On macOS, the default button is designated with special coloration. If | |
/// more than one control is assigned this shortcut, only the first one is | |
/// emphasized. | |
public static let defaultAction: KeyboardShortcut | |
/// The standard keyboard shortcut for cancelling the in-progress action | |
/// or dismissing a prompt, consisting of the Escape (⎋) key and no | |
/// modifiers. | |
public static let cancelAction: KeyboardShortcut | |
/// The key equivalent that the user presses in conjunction with any | |
/// specified modifier keys to activate the shortcut. | |
public var key: KeyEquivalent | |
/// The modifier keys that the user presses in conjunction with a key | |
/// equivalent to activate the shortcut. | |
public var modifiers: EventModifiers | |
/// The localization strategy to apply to this shortcut. | |
public var localization: KeyboardShortcut.Localization | |
/// Creates a new keyboard shortcut with the given key equivalent and set of | |
/// modifier keys. | |
/// | |
/// The localization configuration defaults to ``KeyboardShortcut/Localization-swift.struct/automatic``. | |
public init(_ key: KeyEquivalent, modifiers: EventModifiers = .command) | |
/// Creates a new keyboard shortcut with the given key equivalent and set of | |
/// modifier keys. | |
/// | |
/// Use the `localization` parameter to specify a localization strategy | |
/// for this shortcut. | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init(_ key: KeyEquivalent, modifiers: EventModifiers = .command, localization: KeyboardShortcut.Localization) | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension KeyboardShortcut : Hashable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (lhs: KeyboardShortcut, rhs: KeyboardShortcut) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
/// A standard label for user interface items, consisting of an icon with a | |
/// title. | |
/// | |
/// One of the most common and recognizable user interface components is the | |
/// combination of an icon and a label. This idiom appears across many kinds of | |
/// apps and shows up in collections, lists, menus of action items, and | |
/// disclosable lists, just to name a few. | |
/// | |
/// You create a label, in its simplest form, by providing a title and the name | |
/// of an image, such as an icon from the | |
/// [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/) | |
/// collection: | |
/// | |
/// Label("Lightning", systemImage: "bolt.fill") | |
/// | |
/// You can also apply styles to labels in several ways. In the case of dynamic | |
/// changes to the view after device rotation or change to a window size you | |
/// might want to show only the text portion of the label using the | |
/// ``LabelStyle/titleOnly`` label style: | |
/// | |
/// Label("Lightning", systemImage: "bolt.fill") | |
/// .labelStyle(.titleOnly) | |
/// | |
/// Conversely, there's also an icon-only label style: | |
/// | |
/// Label("Lightning", systemImage: "bolt.fill") | |
/// .labelStyle(.iconOnly) | |
/// | |
/// Some containers might apply a different default label style, such as only | |
/// showing icons within toolbars on macOS and iOS. To opt in to showing both | |
/// the title and the icon, you can apply the ``LabelStyle/titleAndIcon`` label | |
/// style: | |
/// | |
/// Label("Lightning", systemImage: "bolt.fill") | |
/// .labelStyle(.titleAndIcon) | |
/// | |
/// You can also create a customized label style by modifying an existing | |
/// style; this example adds a red border to the default label style: | |
/// | |
/// struct RedBorderedLabelStyle: LabelStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// Label(configuration) | |
/// .border(Color.red) | |
/// } | |
/// } | |
/// | |
/// For more extensive customization or to create a completely new label style, | |
/// you'll need to adopt the ``LabelStyle`` protocol and implement a | |
/// ``LabelStyleConfiguration`` for the new style. | |
/// | |
/// To apply a common label style to a group of labels, apply the style | |
/// to the view hierarchy that contains the labels: | |
/// | |
/// VStack { | |
/// Label("Rain", systemImage: "cloud.rain") | |
/// Label("Snow", systemImage: "snow") | |
/// Label("Sun", systemImage: "sun.max") | |
/// } | |
/// .labelStyle(.iconOnly) | |
/// | |
/// It's also possible to make labels using views to compose the label's icon | |
/// programmatically, rather than using a pre-made image. In this example, the | |
/// icon portion of the label uses a filled ``Circle`` overlaid | |
/// with the user's initials: | |
/// | |
/// Label { | |
/// Text(person.fullName) | |
/// .font(.body) | |
/// .foregroundColor(.primary) | |
/// Text(person.title) | |
/// .font(.subheadline) | |
/// .foregroundColor(.secondary) | |
/// } icon: { | |
/// Circle() | |
/// .fill(person.profileColor) | |
/// .frame(width: 44, height: 44, alignment: .center) | |
/// .overlay(Text(person.initials)) | |
/// } | |
/// | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct Label<Title, Icon> : View where Title : View, Icon : View { | |
/// Creates a label with a custom title and icon. | |
public init(@ViewBuilder title: () -> Title, @ViewBuilder icon: () -> Icon) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Label where Title == Text, Icon == Image { | |
/// Creates a label with an icon image and a title generated from a | |
/// localized string. | |
/// | |
/// - Parameters: | |
/// - titleKey: A title generated from a localized string. | |
/// - image: The name of the image resource to lookup. | |
public init(_ titleKey: LocalizedStringKey, image name: String) | |
/// Creates a label with a system icon image and a title generated from a | |
/// localized string. | |
/// | |
/// - Parameters: | |
/// - titleKey: A title generated from a localized string. | |
/// - systemImage: The name of the image resource to lookup. | |
public init(_ titleKey: LocalizedStringKey, systemImage name: String) | |
/// Creates a label with an icon image and a title generated from a string. | |
/// | |
/// - Parameters: | |
/// - title: A string used as the label's title. | |
/// - image: The name of the image resource to lookup. | |
public init<S>(_ title: S, image name: String) where S : StringProtocol | |
/// Creates a label with a system icon image and a title generated from a | |
/// string. | |
/// | |
/// - Parameters: | |
/// - title: A string used as the label's title. | |
/// - systemImage: The name of the image resource to lookup. | |
public init<S>(_ title: S, systemImage name: String) where S : StringProtocol | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Label where Title == LabelStyleConfiguration.Title, Icon == LabelStyleConfiguration.Icon { | |
/// Creates a label representing the configuration of a style. | |
/// | |
/// You can use this initializer within the ``LabelStyle/makeBody(configuration:)`` | |
/// method of a ``LabelStyle`` instance to create an instance of the label | |
/// that's being styled. This is useful for custom label styles that only | |
/// wish to modify the current style, as opposed to implementing a brand new | |
/// style. | |
/// | |
/// For example, the following style adds a red border around the label, | |
/// but otherwise preserves the current style: | |
/// | |
/// struct RedBorderedLabelStyle: LabelStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// Label(configuration) | |
/// .border(Color.red) | |
/// } | |
/// } | |
/// | |
/// - Parameter configuration: The label style to use. | |
public init(_ configuration: LabelStyleConfiguration) | |
} | |
/// A type that applies a custom appearance to all labels within a view. | |
/// | |
/// To configure the current label style for a view hierarchy, use the | |
/// ``View/labelStyle(_:)`` modifier. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol LabelStyle { | |
/// A view that represents the body of a label. | |
associatedtype Body : View | |
/// Creates a view that represents the body of a label. | |
/// | |
/// The system calls this method for each ``Label`` instance in a view | |
/// hierarchy where this style is the current label style. | |
/// | |
/// - Parameter configuration: The properties of the label. | |
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body | |
/// The properties of a label. | |
typealias Configuration = LabelStyleConfiguration | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LabelStyle where Self == IconOnlyLabelStyle { | |
/// A label style that only displays the icon of the label. | |
/// | |
/// The title of the label is still used for non-visual descriptions, such as | |
/// VoiceOver. | |
public static var iconOnly: IconOnlyLabelStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LabelStyle where Self == TitleOnlyLabelStyle { | |
/// A label style that only displays the title of the label. | |
public static var titleOnly: TitleOnlyLabelStyle { get } | |
} | |
@available(iOS 14.5, macOS 11.3, tvOS 14.5, watchOS 7.4, *) | |
extension LabelStyle where Self == TitleAndIconLabelStyle { | |
/// A label style that shows both the title and icon of the label using a | |
/// system-standard layout. | |
/// | |
/// In most cases, labels show both their title and icon by default. However, | |
/// some containers might apply a different default label style to their | |
/// content, such as only showing icons within toolbars on macOS and iOS. To | |
/// opt in to showing both the title and the icon, you can apply the title | |
/// and icon label style: | |
/// | |
/// Label("Lightning", systemImage: "bolt.fill") | |
/// .labelStyle(.titleAndIcon) | |
/// | |
/// To apply the title and icon style to a group of labels, apply the style | |
/// to the view hierarchy that contains the labels: | |
/// | |
/// VStack { | |
/// Label("Rain", systemImage: "cloud.rain") | |
/// Label("Snow", systemImage: "snow") | |
/// Label("Sun", systemImage: "sun.max") | |
/// } | |
/// .labelStyle(.titleAndIcon) | |
/// | |
/// The relative layout of the title and icon is dependent on the context it | |
/// is displayed in. In most cases, however, the label is arranged | |
/// horizontally with the icon leading. | |
public static var titleAndIcon: TitleAndIconLabelStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LabelStyle where Self == DefaultLabelStyle { | |
/// A label style that resolves its appearance automatically based on the | |
/// current context. | |
public static var automatic: DefaultLabelStyle { get } | |
} | |
/// The properties of a label. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct LabelStyleConfiguration { | |
/// A type-erased title view of a label. | |
public struct Title { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A type-erased icon view of a label. | |
public struct Icon { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A description of the labeled item. | |
public var title: LabelStyleConfiguration.Title { get } | |
/// A symbolic representation of the labeled item. | |
public var icon: LabelStyleConfiguration.Icon { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LabelStyleConfiguration.Title : View { | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LabelStyleConfiguration.Icon : View { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public enum LayoutDirection : Hashable, CaseIterable { | |
case leftToRight | |
case rightToLeft | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: LayoutDirection, b: LayoutDirection) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [LayoutDirection] | |
/// A collection of all values of this type. | |
public static var allCases: [LayoutDirection] { get } | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
extension LayoutDirection { | |
/// Create a direction from its UITraitEnvironmentLayoutDirection equivalent. | |
@available(iOS 14.0, tvOS 14.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
public init?(_ uiLayoutDirection: UITraitEnvironmentLayoutDirection) | |
} | |
/// A container view that arranges its child views in a grid that | |
/// grows horizontally, creating items only as needed. | |
/// | |
/// The grid is "lazy," in that the grid view does not create items until | |
/// they are needed. | |
/// | |
/// In the following example, a ``ScrollView`` contains a `LazyHGrid` that | |
/// consists of a horizontally-arranged grid of ``Text`` views, aligned to | |
/// the top of the scroll view. For each column in the grid, the top row shows | |
/// a Unicode code point from the "Smileys" group, and the bottom shows its | |
/// corresponding emoji. | |
/// | |
/// var rows: [GridItem] = | |
/// Array(repeating: .init(.fixed(20)), count: 2) | |
/// ScrollView(.horizontal) { | |
/// LazyHGrid(rows: rows, alignment: .top) { | |
/// ForEach((0...79), id: \.self) { | |
/// let codepoint = $0 + 0x1f600 | |
/// let codepointString = String(format: "%02X", codepoint) | |
/// Text("\(codepointString)") | |
/// .font(.footnote) | |
/// let emoji = String(Character(UnicodeScalar(codepoint)!)) | |
/// Text("\(emoji)") | |
/// .font(.largeTitle) | |
/// } | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct LazyHGrid<Content> : View where Content : View { | |
/// Creates a grid that grows horizontally, given the provided properties. | |
/// | |
/// - Parameters: | |
/// - rows: An array of grid items to size and position each column of | |
/// the grid. | |
/// - alignment: The alignment of the grid within its parent view. | |
/// - spacing: The spacing between the grid and the next item in its | |
/// parent view. | |
/// - pinnedViews: Views to pin to the bounds of a parent scroll view. | |
/// - content: The content of the grid. | |
public init(rows: [GridItem], alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A view that arranges its children in a line that grows horizontally, | |
/// creating items only as needed. | |
/// | |
/// The stack is "lazy," in that the stack view doesn't create items until | |
/// it needs to render them onscreen. | |
/// | |
/// In the following example, a ``ScrollView`` contains a `LazyHStack` that | |
/// consists of a horizontal row of text views. The stack aligns to the top | |
/// of the scroll view and uses 10-point spacing between each text view. | |
/// | |
/// ScrollView(.horizontal) { | |
/// LazyHStack(alignment: .top, spacing: 10) { | |
/// ForEach(1...100, id: \.self) { | |
/// Text("Column \($0)") | |
/// } | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct LazyHStack<Content> : View where Content : View { | |
/// Creates a lazy horizontal stack view with the given spacing, | |
/// vertical alignment, pinning behavior, and content. | |
/// | |
/// - Parameters: | |
/// - alignment: The guide for aligning the subviews in this stack. All | |
/// child views have the same vertical screen coordinate. | |
/// - spacing: The distance between adjacent subviews, or `nil` if you | |
/// want the stack to choose a default distance for each pair of | |
/// subviews. | |
/// - pinnedViews: The kinds of child views that will be pinned. | |
/// - content: A view builder that creates the content of this stack. | |
public init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A container view that arranges its child views in a grid that | |
/// grows vertically, creating items only as needed. | |
/// | |
/// The grid is "lazy," in that the grid view does not create items until | |
/// they are needed. | |
/// | |
/// In the following example, a ``ScrollView`` contains a | |
/// `LazyVGrid` consisting of a two-column grid of ``Text`` views, showing | |
/// Unicode code points from the "Smileys" group and their corresponding emoji: | |
/// | |
/// var columns: [GridItem] = | |
/// Array(repeating: .init(.flexible()), count: 2) | |
/// ScrollView { | |
/// LazyVGrid(columns: columns) { | |
/// ForEach((0...79), id: \.self) { | |
/// let codepoint = $0 + 0x1f600 | |
/// let codepointString = String(format: "%02X", codepoint) | |
/// Text("\(codepointString)") | |
/// let emoji = String(Character(UnicodeScalar(codepoint)!)) | |
/// Text("\(emoji)") | |
/// } | |
/// }.font(.largeTitle) | |
/// } | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct LazyVGrid<Content> : View where Content : View { | |
/// Creates a grid that grows vertically, given the provided properties. | |
/// | |
/// - Parameters: | |
/// - columns: An array of grid items to size and position each row of | |
/// the grid. | |
/// - alignment: The alignment of the grid within its parent view. | |
/// - spacing: The spacing between the grid and the next item in its | |
/// parent view. | |
/// - pinnedViews: Views to pin to the bounds of a parent scroll view. | |
/// - content: The content of the grid. | |
public init(columns: [GridItem], alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A view that arranges its children in a line that grows vertically, | |
/// creating items only as needed. | |
/// | |
/// The stack is "lazy," in that the stack view doesn't create items until | |
/// it needs to render them onscreen. | |
/// | |
/// In the following example, a ``ScrollView`` contains a `LazyVStack` that | |
/// consists of a vertical row of text views. The stack aligns to the | |
/// leading edge of the scroll view, and uses default spacing between the | |
/// text views. | |
/// | |
/// ScrollView { | |
/// LazyVStack(alignment: .leading) { | |
/// ForEach(1...100, id: \.self) { | |
/// Text("Row \($0)") | |
/// } | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct LazyVStack<Content> : View where Content : View { | |
/// Creates a lazy vertical stack view with the given spacing, | |
/// vertical alignment, pinning behavior, and content. | |
/// | |
/// - Parameters: | |
/// - alignment: The guide for aligning the subviews in this stack. All | |
/// child views have the same horizontal screen coordinate. | |
/// - spacing: The distance between adjacent subviews, or `nil` if you | |
/// want the stack to choose a default distance for each pair of | |
/// subviews. | |
/// - pinnedViews: The kinds of child views that will be pinned. | |
/// - content: A view builder that creates the content of this stack. | |
public init(alignment: HorizontalAlignment = .center, spacing: CGFloat? = nil, pinnedViews: PinnedScrollableViews = .init(), @ViewBuilder content: () -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// The Accessibility Bold Text user setting options. | |
/// | |
/// The app can't override the user's choice. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public enum LegibilityWeight : Hashable { | |
/// Use regular font weight (no Accessibility Bold). | |
case regular | |
/// Use heavier font weight (force Accessibility Bold). | |
case bold | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: LegibilityWeight, b: LegibilityWeight) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
extension LegibilityWeight { | |
/// Creates a legibility weight from its UILegibilityWeight equivalent. | |
@available(iOS 14.0, tvOS 14.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
public init?(_ uiLegibilityWeight: UILegibilityWeight) | |
} | |
/// A linear gradient. | |
/// | |
/// The gradient applies the color function along an axis, as defined by its | |
/// start and end points. The gradient maps the unit space points into the | |
/// bounding rectangle of each shape filled with the gradient. | |
/// | |
/// When using a linear gradient as a shape style, you can also use | |
/// ``ShapeStyle/linearGradient(_:startPoint:endPoint:)``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct LinearGradient : ShapeStyle, View { | |
/// Creates a linear gradient from a base gradient. | |
public init(gradient: Gradient, startPoint: UnitPoint, endPoint: UnitPoint) | |
/// Creates a linear gradient from a collection of colors. | |
public init(colors: [Color], startPoint: UnitPoint, endPoint: UnitPoint) | |
/// Creates a linear gradient from a collection of color stops. | |
public init(stops: [Gradient.Stop], startPoint: UnitPoint, endPoint: UnitPoint) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
/// A progress view that visually indicates its progress using a horizontal bar. | |
/// | |
/// Do not use this type directly. Instead, use ``ProgressViewStyle/linear``. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct LinearProgressViewStyle : ProgressViewStyle { | |
/// Creates a linear progress view style. | |
public init() | |
/// Creates a linear progress view style with a tint color. | |
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
@available(tvOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
public init(tint: Color) | |
/// Creates a view representing the body of a progress view. | |
/// | |
/// - Parameter configuration: The properties of the progress view being | |
/// created. | |
/// | |
/// The view hierarchy calls this method for each progress view where this | |
/// style is the current progress view style. | |
/// | |
/// - Parameter configuration: The properties of the progress view, such as | |
/// its preferred progress type. | |
public func makeBody(configuration: LinearProgressViewStyle.Configuration) -> some View | |
/// A view representing the body of a progress view. | |
public typealias Body = some View | |
} | |
/// A control for navigating to a URL. | |
/// | |
/// You create a link by providing a destination URL and a title. The title | |
/// tells the user the purpose of the link, which can be either a string, or a | |
/// title key that returns a localized string used to construct a label | |
/// displayed to the user in your app's UI. The example below creates a link to | |
/// `example.com` and displays the title string you provide as a | |
/// link-styled view in your app: | |
/// | |
/// Link("View Our Terms of Service", | |
/// destination: URL(string: "https://www.example.com/TOS.html")!) | |
/// | |
/// When a user taps or clicks a `Link`, where the URL opens depends on the | |
/// contents of the URL. For example, a Universal Link will open in the | |
/// associated app, if possible, but otherwise in the user's default web | |
/// browser. | |
/// | |
/// As with other views, you can style links using standard view modifiers | |
/// depending on the view type of the link's label. For example, a ``Text`` | |
/// label could be modified with a custom ``View/font(_:)`` or | |
/// ``View/foregroundColor(_:)`` to customize the appearance of the link in | |
/// your app's UI. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct Link<Label> : View where Label : View { | |
/// Creates a control, consisting of a URL and a label, used to navigate | |
/// to the given URL. | |
/// | |
/// - Parameters: | |
/// - destination: The URL for the link. | |
/// - label: A view that describes the destination of URL. | |
public init(destination: URL, @ViewBuilder label: () -> Label) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Link where Label == Text { | |
/// Creates a control, consisting of a URL and a title key, used to | |
/// navigate to a URL. | |
/// | |
/// Use ``Link`` to create a control that your app uses to navigate to a | |
/// URL that you provide. The example below creates a link to | |
/// `example.com` and uses `Visit Example Co` as the title key to | |
/// generate a link-styled view in your app: | |
/// | |
/// Link("Visit Example Co", | |
/// destination: URL(string: "https://www.example.com/")!) | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title that describes the | |
/// purpose of this link. | |
/// - destination: The URL for the link. | |
public init(_ titleKey: LocalizedStringKey, destination: URL) | |
/// Creates a control, consisting of a URL and a title string, used to | |
/// navigate to a URL. | |
/// | |
/// Use ``Link`` to create a control that your app uses to navigate to a | |
/// URL that you provide. The example below creates a link to | |
/// `example.com` and displays the title string you provide as a | |
/// link-styled view in your app: | |
/// | |
/// func marketingLink(_ callToAction: String) -> Link { | |
/// Link(callToAction, | |
/// destination: URL(string: "https://www.example.com/")!) | |
/// } | |
/// | |
/// - Parameters: | |
/// - title: A text string used as the title for describing the | |
/// underlying `destination` URL. | |
/// - destination: The URL for the link. | |
public init<S>(_ title: S, destination: URL) where S : StringProtocol | |
} | |
/// A container that presents rows of data arranged in a single column, | |
/// optionally providing the ability to select one or more members. | |
/// | |
/// In its simplest form, a `List` creates its contents statically, as shown in | |
/// the following example: | |
/// | |
/// var body: some View { | |
/// List { | |
/// Text("A List Item") | |
/// Text("A Second List Item") | |
/// Text("A Third List Item") | |
/// } | |
/// } | |
/// | |
/// ![A vertical list with three text views.](SwiftUI-List-static.png) | |
/// | |
/// More commonly, you create lists dynamically from an underlying collection | |
/// of data. The following example shows how to create a simple list from an | |
/// array of an `Ocean` type which conforms to | |
/// <doc://com.apple.documentation/documentation/Swift/Identifiable>: | |
/// | |
/// struct Ocean: Identifiable { | |
/// let name: String | |
/// let id = UUID() | |
/// } | |
/// private var oceans = [ | |
/// Ocean(name: "Pacific"), | |
/// Ocean(name: "Atlantic"), | |
/// Ocean(name: "Indian"), | |
/// Ocean(name: "Southern"), | |
/// Ocean(name: "Arctic") | |
/// ] | |
/// | |
/// var body: some View { | |
/// List(oceans) { | |
/// Text($0.name) | |
/// } | |
/// } | |
/// | |
/// ![A vertical list with five text views, each with the name of an | |
/// ocean.](SwiftUI-List-collection.png) | |
/// | |
/// ### Supporting Selection in Lists | |
/// | |
/// To make members of a list selectable, provide a binding to a selection | |
/// variable. Binding to a single instance of the list data's `Identifiable.ID` | |
/// type creates a single-selection list. Binding to a | |
/// <doc://com.apple.documentation/documentation/Swift/Set> creates a list that | |
/// supports multiple selections. The following example shows how to add | |
/// multi-select to the previous | |
/// example. A ``Text`` view below the list shows the number of items | |
/// currently selected. | |
/// | |
/// struct Ocean: Identifiable, Hashable { | |
/// let name: String | |
/// let id = UUID() | |
/// } | |
/// private var oceans = [ | |
/// Ocean(name: "Pacific"), | |
/// Ocean(name: "Atlantic"), | |
/// Ocean(name: "Indian"), | |
/// Ocean(name: "Southern"), | |
/// Ocean(name: "Arctic") | |
/// ] | |
/// @State private var multiSelection = Set<UUID>() | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// List(oceans, selection: $multiSelection) { | |
/// Text($0.name) | |
/// } | |
/// .navigationTitle("Oceans") | |
/// .toolbar { EditButton() } | |
/// } | |
/// Text("\(multiSelection.count) selections") | |
/// } | |
/// | |
/// ![A navigation view with the title Oceans and an active edit button with | |
/// the title Done. Below this, a vertical list with five text views, each with | |
/// the name of an ocean. Each text view has a circle to indicate selectability, | |
/// and two of these circles are selected. At the bottom, a text view reads | |
/// 2 selection(s).](SwiftUI-List-multi-selection.png) | |
/// | |
/// ### Refreshing the List Content | |
/// | |
/// To make the content of the list refreshable using the standard refresh | |
/// control, use the ``View/refreshable(action:)`` modifier. | |
/// | |
/// The following example shows how to add a standard refresh control to a list. | |
/// When the user drags the top of the list downward, SwiftUI reveals the refresh | |
/// control and executes the specified action. Use an `await` expression | |
/// inside the `action` closure to refresh your data. The refresh indicator remains | |
/// visible for the duration of the awaited operation. | |
/// | |
/// struct Ocean: Identifiable, Hashable { | |
/// let name: String | |
/// let id = UUID() | |
/// let stats: [String: String] | |
/// } | |
/// class OceanStore: ObservableObject { | |
/// @Published var oceans = [Ocean]() | |
/// func loadStats() async -> Void {} | |
/// } | |
/// @EnvironmentObject var store: OceanStore | |
/// var body: some View { | |
/// NavigationView { | |
/// List(store.oceans) { ocean in | |
/// HStack { | |
/// Text(ocean.name) | |
/// StatsSummary(stats: ocean.stats) // A custom view for showing statistics. | |
/// } | |
/// } | |
/// .refreshable { | |
/// await store.loadStats() | |
/// } | |
/// .navigationTitle("Oceans") | |
/// } | |
/// } | |
/// | |
/// ### Supporting Multi-Dimensional Lists | |
/// | |
/// To support two-dimensional lists, your list's content can create instances | |
/// of the ``Section`` type, which then provide their own contents. | |
/// | |
/// The following example creates sections named after the world's oceans, | |
/// each of which has ``Text`` children named for major seas attached to those | |
/// oceans. The example also allows for selection of a single list item, | |
/// identified by the `id` of the example's `Sea` type. | |
/// | |
/// struct ContentView: View { | |
/// struct Sea: Hashable, Identifiable { | |
/// let name: String | |
/// let id = UUID() | |
/// } | |
/// struct OceanRegion: Identifiable { | |
/// let name: String | |
/// let seas: [Sea] | |
/// let id = UUID() | |
/// } | |
/// private let oceanRegions: [OceanRegion] = [ | |
/// OceanRegion(name: "Pacific", | |
/// seas: [Sea(name: "Australasian Mediterranean"), | |
/// Sea(name: "Philippine"), | |
/// Sea(name: "Coral"), | |
/// Sea(name: "South China")]), | |
/// OceanRegion(name: "Atlantic", | |
/// seas: [Sea(name: "American Mediterranean"), | |
/// Sea(name: "Sargasso"), | |
/// Sea(name: "Caribbean")]), | |
/// OceanRegion(name: "Indian", | |
/// seas: [Sea(name: "Bay of Bengal")]), | |
/// OceanRegion(name: "Southern", | |
/// seas: [Sea(name:"Weddell")]), | |
/// OceanRegion(name: "Arctic", | |
/// seas: [Sea(name: "Greenland")]) | |
/// ] | |
/// @State private var singleSelection : UUID? | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// List(selection: $singleSelection){ | |
/// ForEach(oceanRegions) { region in | |
/// Section(header: Text("Major \(region.name) Ocean Seas")) { | |
/// ForEach(region.seas) { sea in | |
/// Text(sea.name) | |
/// } | |
/// } | |
/// } | |
/// } | |
/// .navigationTitle("Oceans and Seas") | |
/// .toolbar { EditButton() } | |
/// } | |
/// } | |
/// } | |
/// | |
/// ![A vertical list split into sections titled Major Pacific Ocean Seas, | |
/// Major Atlantic Ocean Seas, etc. Each section has a different number of | |
/// rows, with the names of various seas. Within the Major Atlantic Ocean | |
/// Seas section, the row Sargasso is | |
/// selected.](SwiftUI-List-sections-defaultListStyle.png) | |
/// | |
/// ### Creating Hierarchical Lists | |
/// | |
/// You can also create a hierarchical list of arbitrary depth by providing | |
/// tree-structured data and a `children` parameter that provides a key path to | |
/// get the child nodes at any level. The following example uses a deeply-nested | |
/// collection of a custom `FileItem` type to simulate the contents of a | |
/// file system. The list created from this data uses collapsing cells to allow | |
/// the user to navigate the tree structure. | |
/// | |
/// struct ContentView: View { | |
/// struct FileItem: Hashable, Identifiable, CustomStringConvertible { | |
/// var id: Self { self } | |
/// var name: String | |
/// var children: [FileItem]? = nil | |
/// var description: String { | |
/// switch children { | |
/// case nil: | |
/// return "📄 \(name)" | |
/// case .some(let children): | |
/// return children.isEmpty ? "📂 \(name)" : "📁 \(name)" | |
/// } | |
/// } | |
/// } | |
/// let fileHierarchyData: [FileItem] = [ | |
/// FileItem(name: "users", children: | |
/// [FileItem(name: "user1234", children: | |
/// [FileItem(name: "Photos", children: | |
/// [FileItem(name: "photo001.jpg"), | |
/// FileItem(name: "photo002.jpg")]), | |
/// FileItem(name: "Movies", children: | |
/// [FileItem(name: "movie001.mp4")]), | |
/// FileItem(name: "Documents", children: []) | |
/// ]), | |
/// FileItem(name: "newuser", children: | |
/// [FileItem(name: "Documents", children: []) | |
/// ]) | |
/// ]), | |
/// FileItem(name: "private", children: nil) | |
/// ] | |
/// var body: some View { | |
/// List(fileHierarchyData, children: \.children) { item in | |
/// Text(item.description) | |
/// } | |
/// } | |
/// } | |
/// | |
/// ![A list providing a drill-down view of a tree structure. Each row | |
/// expands to show its children, which are indented slightly. The top row | |
/// is titled users, with users1234 below it, below which are rows titled | |
/// Photos, Movies, and Documents, each with a folder | |
/// icon.](SwiftUI-List-hierarchical.png) | |
/// | |
/// ### Styling Lists | |
/// | |
/// SwiftUI chooses a display style for a list based on the platform and the | |
/// view type in which it appears. Use the ``View/listStyle(_:)`` modifier to | |
/// apply a different ``ListStyle`` to all lists within a view. For example, | |
/// adding `.listStyle(.insetGrouped)` to the example shown in the | |
/// "Creating Multi-Dimensional Lists" topic applies the | |
/// ``ListStyle/insetGrouped`` style, as seen in the following screenshot. | |
/// | |
/// ![A vertical list split into sections titled Major Pacific Ocean Seas, | |
/// Major Atlantic Ocean Seas, etc. Each section has a different number of | |
/// rows, with the names of various seas. Within the Major Atlantic Ocean | |
/// Seas section, the row Sargasso is selected. The sections display a border | |
/// around the sides of each list item, connecting with the section headers, | |
/// which provides a visual grouping not provided by the default list | |
/// style.](SwiftUI-List-sections-insetGroupedListStyle.png) | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct List<SelectionValue, Content> : View where SelectionValue : Hashable, Content : View { | |
/// Creates a list with the given content that supports selecting multiple | |
/// rows. | |
/// | |
/// On iOS and tvOS, you must explicitly put the list into edit mode for | |
/// the selection to apply. | |
/// | |
/// - Parameters: | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - content: The content of the list. | |
@available(watchOS, unavailable) | |
public init(selection: Binding<Set<SelectionValue>>?, @ViewBuilder content: () -> Content) | |
/// Creates a list with the given content that supports selecting a single | |
/// row. | |
/// | |
/// On iOS and tvOS, you must explicitly put the list into edit mode for | |
/// the selection to apply. | |
/// | |
/// - Parameters: | |
/// - selection: A binding to a selected row. | |
/// - content: The content of the list. | |
@available(watchOS, unavailable) | |
public init(selection: Binding<SelectionValue?>?, @ViewBuilder content: () -> Content) | |
/// The content of the list. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension List { | |
/// Creates a list that computes its rows on demand from an underlying | |
/// collection of identifiable data, optionally allowing users to select | |
/// multiple rows. | |
/// | |
/// - Parameters: | |
/// - data: The identifiable data for computing the list. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Data, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, Data.Element.ID, RowContent>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable | |
/// Creates a hierarchical list that computes its rows on demand from an | |
/// underlying collection of identifiable data, optionally allowing users to | |
/// select multiple rows. | |
/// | |
/// - Parameters: | |
/// - data: The identifiable data for computing the list. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable | |
/// Creates a list that identifies its rows based on a key path to the | |
/// identifier of the underlying data, optionally allowing users to select | |
/// multiple rows. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, RowContent>, Data : RandomAccessCollection, ID : Hashable, RowContent : View | |
/// Creates a hierarchical list that identifies its rows based on a key path | |
/// to the identifier of the underlying data, optionally allowing users to | |
/// select multiple rows. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes a node capable | |
/// of having children that is currently childless, such as an empty | |
/// directory in a file system. On the other hand, if the property at the | |
/// key path is `nil`, then `data` is treated as a leaf node in the tree, | |
/// like a regular file in a file system. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, children: KeyPath<Data.Element, Data?>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View | |
/// Creates a list that computes its views on demand over a constant range, | |
/// optionally allowing users to select multiple rows. | |
/// | |
/// This instance only reads the initial value of `data` and doesn't need to | |
/// identify views across updates. To compute views on demand over a dynamic | |
/// range, use ``List/init(_:id:selection:rowContent:)-8ef64``. | |
/// | |
/// - Parameters: | |
/// - data: A constant range of data to populate the list. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<RowContent>(_ data: Range<Int>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Int) -> RowContent) where Content == ForEach<Range<Int>, Int, HStack<RowContent>>, RowContent : View | |
/// Creates a list that computes its rows on demand from an underlying | |
/// collection of identifiable data, optionally allowing users to select a | |
/// single row. | |
/// | |
/// - Parameters: | |
/// - data: The identifiable data for computing the list. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Data, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, Data.Element.ID, RowContent>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable | |
/// Creates a hierarchical list that computes its rows on demand from an | |
/// underlying collection of identifiable data, optionally allowing users to | |
/// select a single row. | |
/// | |
/// - Parameters: | |
/// - data: The identifiable data for computing the list. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes a node capable | |
/// of having children that is currently childless, such as an empty | |
/// directory in a file system. On the other hand, if the property at the | |
/// key path is `nil`, then `data` is treated as a leaf node in the tree, | |
/// like a regular file in a file system. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable | |
/// Creates a list that identifies its rows based on a key path to the | |
/// identifier of the underlying data, optionally allowing users to select a | |
/// single row. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, RowContent>, Data : RandomAccessCollection, ID : Hashable, RowContent : View | |
/// Creates a hierarchical list that identifies its rows based on a key path | |
/// to the identifier of the underlying data, optionally allowing users to | |
/// select a single row. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes a node capable | |
/// of having children that is currently childless, such as an empty | |
/// directory in a file system. On the other hand, if the property at the | |
/// key path is `nil`, then `data` is treated as a leaf node in the tree, | |
/// like a regular file in a file system. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, children: KeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View | |
/// Creates a list that computes its views on demand over a constant range, | |
/// optionally allowing users to select a single row. | |
/// | |
/// This instance only reads the initial value of `data` and doesn't need to | |
/// identify views across updates. To compute views on demand over a dynamic | |
/// range, use ``List/init(_:id:selection:rowContent:)-9r2hz``. | |
/// | |
/// - Parameters: | |
/// - data: A constant range of data to populate the list. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<RowContent>(_ data: Range<Int>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Int) -> RowContent) where Content == ForEach<Range<Int>, Int, RowContent>, RowContent : View | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension List where SelectionValue == Never { | |
/// Creates a list with the given content. | |
/// | |
/// - Parameter content: The content of the list. | |
public init(@ViewBuilder content: () -> Content) | |
/// Creates a list that computes its rows on demand from an underlying | |
/// collection of identifiable data. | |
/// | |
/// - Parameters: | |
/// - data: A collection of identifiable data for computing the list. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
public init<Data, RowContent>(_ data: Data, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, Data.Element.ID, RowContent>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable | |
/// Creates a hierarchical list that computes its rows on demand from an | |
/// underlying collection of identifiable data. | |
/// | |
/// - Parameters: | |
/// - data: A collection of identifiable data for computing the list. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes a node capable | |
/// of having children that is currently childless, such as an empty | |
/// directory in a file system. On the other hand, if the property at the | |
/// key path is `nil`, then `data` is treated as a leaf node in the tree, | |
/// like a regular file in a file system. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable | |
/// Creates a list that identifies its rows based on a key path to the | |
/// identifier of the underlying data. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == ForEach<Data, ID, RowContent>, Data : RandomAccessCollection, ID : Hashable, RowContent : View | |
/// Creates a hierarchical list that identifies its rows based on a key path | |
/// to the identifier of the underlying data. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes a node capable | |
/// of having children that is currently childless, such as an empty | |
/// directory in a file system. On the other hand, if the property at the | |
/// key path is `nil`, then `data` is treated as a leaf node in the tree, | |
/// like a regular file in a file system. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Data, id: KeyPath<Data.Element, ID>, children: KeyPath<Data.Element, Data?>, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : RandomAccessCollection, ID : Hashable, RowContent : View | |
/// Creates a list that computes its views on demand over a constant range. | |
/// | |
/// This instance only reads the initial value of `data` and doesn't need to | |
/// identify views across updates. To compute views on demand over a dynamic | |
/// range, use ``List/init(_:id:rowContent:)``. | |
/// | |
/// - Parameters: | |
/// - data: A constant range of data to populate the list. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
public init<RowContent>(_ data: Range<Int>, @ViewBuilder rowContent: @escaping (Int) -> RowContent) where Content == ForEach<Range<Int>, Int, RowContent>, RowContent : View | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension List { | |
/// Creates a list that computes its rows on demand from an underlying | |
/// collection of identifiable data, optionally allowing users to select | |
/// multiple rows. | |
/// | |
/// - Parameters: | |
/// - data: The identifiable data for computing the list. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Binding<Data>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, Data.Element.ID)>, Data.Element.ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable | |
/// Creates a list that identifies its rows based on a key path to the | |
/// identifier of the underlying data, optionally allowing users to select | |
/// multiple rows. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - selection: A binding to a set that identifies selected rows. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, selection: Binding<Set<SelectionValue>>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, ID)>, ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable | |
/// Creates a list that computes its rows on demand from an underlying | |
/// collection of identifiable data, optionally allowing users to select a | |
/// single row. | |
/// | |
/// - Parameters: | |
/// - data: The identifiable data for computing the list. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, RowContent>(_ data: Binding<Data>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, Data.Element.ID)>, Data.Element.ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable | |
/// Creates a list that identifies its rows based on a key path to the | |
/// identifier of the underlying data, optionally allowing users to select a | |
/// single row. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - selection: A binding to a selected value. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
@available(watchOS, unavailable) | |
public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, selection: Binding<SelectionValue?>?, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, ID)>, ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension List where SelectionValue == Never { | |
/// Creates a list that computes its rows on demand from an underlying | |
/// collection of identifiable data. | |
/// | |
/// - Parameters: | |
/// - data: A collection of identifiable data for computing the list. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
public init<Data, RowContent>(_ data: Binding<Data>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, Data.Element.ID)>, Data.Element.ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable, Data.Index : Hashable | |
/// Creates a list that identifies its rows based on a key path to the | |
/// identifier of the underlying data. | |
/// | |
/// - Parameters: | |
/// - data: The data for populating the list. | |
/// - id: The key path to the data model's identifier. | |
/// - rowContent: A view builder that creates the view for a single row of | |
/// the list. | |
public init<Data, ID, RowContent>(_ data: Binding<Data>, id: KeyPath<Data.Element, ID>, @ViewBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == ForEach<LazyMapSequence<Data.Indices, (Data.Index, ID)>, ID, RowContent>, Data : MutableCollection, Data : RandomAccessCollection, ID : Hashable, RowContent : View, Data.Index : Hashable | |
} | |
/// The configuration of a tint effect applied to content within a List. | |
/// | |
/// - See Also: `View.listItemTint(_:)` | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct ListItemTint { | |
/// An explicit tint color. | |
/// | |
/// This tint effect is fixed and not overridable by other | |
/// system effects. | |
public static func fixed(_ tint: Color) -> ListItemTint | |
/// An explicit tint color that is overridable. | |
/// | |
/// This tint effect is overridable by system effects, for | |
/// example when the system has a custom user accent | |
/// color on macOS. | |
public static func preferred(_ tint: Color) -> ListItemTint | |
/// A standard grayscale tint effect. | |
/// | |
/// Monochrome tints are not overridable. | |
public static let monochrome: ListItemTint | |
} | |
/// A protocol that describes the behavior and appearance of a list. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol ListStyle { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ListStyle where Self == DefaultListStyle { | |
/// The list style that describes a platform's default behavior and | |
/// appearance for a list. | |
public static var automatic: DefaultListStyle { get } | |
} | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ListStyle where Self == SidebarListStyle { | |
/// The list style that describes the behavior and appearance of a | |
/// sidebar list. | |
/// | |
/// On macOS and iOS, the sidebar list style displays disclosure indicators in | |
/// the section headers that allow the user to collapse and expand sections. | |
public static var sidebar: SidebarListStyle { get } | |
} | |
@available(iOS 14.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ListStyle where Self == InsetGroupedListStyle { | |
/// The list style that describes the behavior and appearance of an inset | |
/// grouped list. | |
/// | |
/// On iOS, the inset grouped list style displays a continuous background color | |
/// that extends from the section header, around both sides of list items in the | |
/// section, and down to the section footer. This visually groups the items | |
/// to a greater degree than either the ``ListStyle/inset`` or | |
/// ``ListStyle/grouped`` styles do. | |
public static var insetGrouped: InsetGroupedListStyle { get } | |
} | |
@available(iOS 13.0, tvOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ListStyle where Self == GroupedListStyle { | |
/// The list style that describes the behavior and appearance of a grouped | |
/// list. | |
/// | |
/// On iOS, the grouped list style displays a larger header and footer than | |
/// the ``ListStyle/plain`` style, which visually distances the members of | |
/// different sections. | |
public static var grouped: GroupedListStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ListStyle where Self == InsetListStyle { | |
/// The list style that describes the behavior and appearance of an inset | |
/// list. | |
public static var inset: InsetListStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ListStyle where Self == PlainListStyle { | |
/// The list style that describes the behavior and appearance of a plain | |
/// list. | |
public static var plain: PlainListStyle { get } | |
} | |
/// The key used to look up an entry in a strings file or strings dictionary | |
/// file. | |
/// | |
/// Initializers for several SwiftUI types -- such as ``Text``, ``Toggle``, | |
/// ``Picker`` and others -- implicitly look up a localized string when you | |
/// provide a string literal. When you use the initializer `Text("Hello")`, | |
/// SwiftUI creates a `LocalizedStringKey` for you and uses that to look up a | |
/// localization of the `Hello` string. This works because `LocalizedStringKey` | |
/// conforms to | |
/// <doc://com.apple.documentation/documentation/Swift/ExpressibleByStringLiteral>. | |
/// | |
/// Types whose initializers take a `LocalizedStringKey` usually have | |
/// a corresponding initializer that accepts a parameter that conforms to | |
/// <doc://com.apple.documentation/documentation/Swift/StringProtocol>. Passing | |
/// a `String` variable to these initializers avoids localization, which is | |
/// usually appropriate when the variable contains a user-provided value. | |
/// | |
/// As a general rule, use a string literal argument when you want | |
/// localization, and a string variable argument when you don't. In the case | |
/// where you want to localize the value of a string variable, use the string to | |
/// create a new `LocalizedStringKey` instance. | |
/// | |
/// The following example shows how to create ``Text`` instances both | |
/// with and without localization. The title parameter provided to the | |
/// ``Section`` is a literal string, so SwiftUI creates a | |
/// `LocalizedStringKey` for it. However, the string entries in the | |
/// `messageStore.today` array are `String` variables, so the ``Text`` views | |
/// in the list use the string values verbatim. | |
/// | |
/// List { | |
/// Section(header: Text("Today")) { | |
/// ForEach(messageStore.today) { message in | |
/// Text(message.title) | |
/// } | |
/// } | |
/// } | |
/// | |
/// If the app is localized into Japanese with the following | |
/// translation of its `Localizable.strings` file: | |
/// | |
/// ```other | |
/// "Today" = "今日"; | |
/// ``` | |
/// | |
/// When run in Japanese, the example produces a | |
/// list like the following, localizing "Today" for the section header, but not | |
/// the list items. | |
/// | |
/// ![A list with a single section header displayed in Japanese. | |
/// The items in the list are all in English: New for Monday, Account update, | |
/// and Server | |
/// maintenance.](SwiftUI-LocalizedStringKey-Today-List-Japanese.png) | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct LocalizedStringKey : Equatable, ExpressibleByStringInterpolation { | |
/// Creates a localized string key from the given string value. | |
/// | |
/// - Parameter value: The string to use as a localization key. | |
public init(_ value: String) | |
/// Creates a localized string key from the given string literal. | |
/// | |
/// - Parameter value: The string literal to use as a localization key. | |
public init(stringLiteral value: String) | |
/// Creates a localized string key from the given string interpolation. | |
/// | |
/// To create a localized string key from a string interpolation, use | |
/// the `\()` string interpolation syntax. Swift matches the parameter | |
/// types in the expression to one of the `appendInterpolation` methods | |
/// in ``LocalizedStringKey/StringInterpolation``. The interpolated | |
/// types can include numeric values, Foundation types, and SwiftUI | |
/// ``Text`` and ``Image`` instances. | |
/// | |
/// The following example uses a string interpolation with two arguments: | |
/// an unlabeled | |
/// <doc://com.apple.documentation/documentation/Foundation/Date> | |
/// and a ``Text/DateStyle`` labeled `style`. The compiler maps these to the | |
/// method | |
/// ``LocalizedStringKey/StringInterpolation/appendInterpolation(_:style:)`` | |
/// as it builds the string that it creates the | |
/// ``LocalizedStringKey`` with. | |
/// | |
/// let key = LocalizedStringKey("Date is \(company.foundedDate, style: .offset)") | |
/// let text = Text(key) // Text contains "Date is +45 years" | |
/// | |
/// You can write this example more concisely, implicitly creating a | |
/// ``LocalizedStringKey`` as the parameter to the ``Text`` | |
/// initializer: | |
/// | |
/// let text = Text("Date is \(company.foundedDate, style: .offset)") | |
/// | |
/// - Parameter stringInterpolation: The string interpolation to use as the | |
/// localization key. | |
public init(stringInterpolation: LocalizedStringKey.StringInterpolation) | |
/// Represents the contents of a string literal with interpolations | |
/// while it’s being built, for use in creating a localized string key. | |
public struct StringInterpolation : StringInterpolationProtocol { | |
/// Creates an empty instance ready to be filled with string literal content. | |
/// | |
/// Don't call this initializer directly. Instead, initialize a variable or | |
/// constant using a string literal with interpolated expressions. | |
/// | |
/// Swift passes this initializer a pair of arguments specifying the size of | |
/// the literal segments and the number of interpolated segments. Use this | |
/// information to estimate the amount of storage you will need. | |
/// | |
/// - Parameter literalCapacity: The approximate size of all literal segments | |
/// combined. This is meant to be passed to `String.reserveCapacity(_:)`; | |
/// it may be slightly larger or smaller than the sum of the counts of each | |
/// literal segment. | |
/// - Parameter interpolationCount: The number of interpolations which will be | |
/// appended. Use this value to estimate how much additional capacity will | |
/// be needed for the interpolated segments. | |
public init(literalCapacity: Int, interpolationCount: Int) | |
/// Appends a literal string. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameter literal: The literal string to append. | |
public mutating func appendLiteral(_ literal: String) | |
/// Appends a literal string segment to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameter string: The literal string to append. | |
public mutating func appendInterpolation(_ string: String) | |
/// Appends an optionally-formatted instance of a Foundation type | |
/// to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameters: | |
/// - subject: The Foundation object to append. | |
/// - formatter: A formatter to convert `subject` to a string | |
/// representation. | |
public mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : ReferenceConvertible | |
/// Appends an optionally-formatted instance of an Objective-C subclass | |
/// to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// The following example shows how to use a | |
/// <doc://com.apple.documentation/documentation/Foundation/Measurement> | |
/// value and a | |
/// <doc://com.apple.documentation/documentation/Foundation/MeasurementFormatter> | |
/// to create a ``LocalizedStringKey`` that uses the formatter | |
/// style | |
/// <doc://com.apple.documentation/documentation/foundation/Formatter/UnitStyle/long> | |
/// when generating the measurement's string representation. Rather than | |
/// calling `appendInterpolation(_:formatter)` directly, the code | |
/// gets the formatting behavior implicitly by using the `\()` | |
/// string interpolation syntax. | |
/// | |
/// let siResistance = Measurement(value: 640, unit: UnitElectricResistance.ohms) | |
/// let formatter = MeasurementFormatter() | |
/// formatter.unitStyle = .long | |
/// let key = LocalizedStringKey ("Resistance: \(siResistance, formatter: formatter)") | |
/// let text1 = Text(key) // Text contains "Resistance: 640 ohms" | |
/// | |
/// - Parameters: | |
/// - subject: An <doc://com.apple.documentation/documentation/objectivec/NSObject> | |
/// to append. | |
/// - formatter: A formatter to convert `subject` to a string | |
/// representation. | |
public mutating func appendInterpolation<Subject>(_ subject: Subject, formatter: Formatter? = nil) where Subject : NSObject | |
/// Appends the interpolation of `F.FormatInput` using a `FormatStyle`. | |
/// | |
/// - Parameters: | |
/// - input: The input to provide to the format style. | |
/// - format: The specific `FormatStyle` to use to convert the input | |
/// into a string. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public mutating func appendInterpolation<F>(_ input: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String | |
/// Appends a type, convertible to a string by using a default format | |
/// specifier, to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameters: | |
/// - value: A primitive type to append, such as | |
/// <doc://com.apple.documentation/documentation/swift/Int>, | |
/// <doc://com.apple.documentation/documentation/swift/UInt32>, or | |
/// <doc://com.apple.documentation/documentation/swift/Double>. | |
public mutating func appendInterpolation<T>(_ value: T) where T : _FormatSpecifiable | |
/// Appends a type, convertible to a string with a format specifier, | |
/// to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameters: | |
/// - value: The value to append. | |
/// - specifier: A format specifier to convert `subject` to a string | |
/// representation, like `%f` for a | |
/// <doc://com.apple.documentation/documentation/swift/Double>, or | |
/// `%x` to create a hexidecimal representation of a | |
/// <doc://com.apple.documentation/documentation/swift/UInt32>. For a | |
/// list of available specifier strings, see | |
/// [String Format Specifers](https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFStrings/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265). | |
public mutating func appendInterpolation<T>(_ value: T, specifier: String) where T : _FormatSpecifiable | |
/// Appends the string displayed by a text view to a string | |
/// interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameters: | |
/// - value: A ``Text`` instance to append. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public mutating func appendInterpolation(_ text: Text) | |
/// Appends an AttributedString to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameter attributedString: The AttributedString to append. | |
@available(macOS 12.0, iOS 15.0, tvOS 15.0, watchOS 8.0, *) | |
public mutating func appendInterpolation(_ attributedString: AttributedString) | |
/// The type that should be used for literal segments. | |
public typealias StringLiteralType = String | |
} | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: LocalizedStringKey, b: LocalizedStringKey) -> Bool | |
/// A type that represents an extended grapheme cluster literal. | |
/// | |
/// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`, | |
/// `String`, and `StaticString`. | |
public typealias ExtendedGraphemeClusterLiteralType = String | |
/// A type that represents a string literal. | |
/// | |
/// Valid types for `StringLiteralType` are `String` and `StaticString`. | |
public typealias StringLiteralType = String | |
/// A type that represents a Unicode scalar literal. | |
/// | |
/// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`, | |
/// `Character`, `String`, and `StaticString`. | |
public typealias UnicodeScalarLiteralType = String | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LocalizedStringKey.StringInterpolation { | |
/// Appends an image to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameter image: The image to append. | |
public mutating func appendInterpolation(_ image: Image) | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension LocalizedStringKey.StringInterpolation { | |
/// Appends a formatted date to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameters: | |
/// - date: The date to append. | |
/// - style: A predefined style to format the date with. | |
public mutating func appendInterpolation(_ date: Date, style: Text.DateStyle) | |
/// Appends a date range to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameter dates: The closed range of dates to append. | |
public mutating func appendInterpolation(_ dates: ClosedRange<Date>) | |
/// Appends a date interval to a string interpolation. | |
/// | |
/// Don't call this method directly; it's used by the compiler when | |
/// interpreting string interpolations. | |
/// | |
/// - Parameter interval: The date interval to append. | |
public mutating func appendInterpolation(_ interval: DateInterval) | |
} | |
/// A gesture that succeeds when the user performs a long press. | |
/// | |
/// To recognize a long-press gesture on a view, create and configure the | |
/// gesture, then add it to the view using the ``View/gesture(_:including:)`` | |
/// modifier. | |
/// | |
/// Add a long-press gesture to a ``Circle`` to animate its color from blue to | |
/// red, and then change it to green when the gesture ends: | |
/// | |
/// struct LongPressGestureView: View { | |
/// @GestureState var isDetectingLongPress = false | |
/// @State var completedLongPress = false | |
/// | |
/// var longPress: some Gesture { | |
/// LongPressGesture(minimumDuration: 3) | |
/// .updating($isDetectingLongPress) { currentState, gestureState, | |
/// transaction in | |
/// gestureState = currentState | |
/// transaction.animation = Animation.easeIn(duration: 2.0) | |
/// } | |
/// .onEnded { finished in | |
/// self.completedLongPress = finished | |
/// } | |
/// } | |
/// | |
/// var body: some View { | |
/// Circle() | |
/// .fill(self.isDetectingLongPress ? | |
/// Color.red : | |
/// (self.completedLongPress ? Color.green : Color.blue)) | |
/// .frame(width: 100, height: 100, alignment: .center) | |
/// .gesture(longPress) | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, tvOS 14.0, *) | |
public struct LongPressGesture : Gesture { | |
/// The minimum duration of the long press that must elapse before the | |
/// gesture succeeds. | |
public var minimumDuration: Double | |
/// The maximum distance that the long press can move before the gesture | |
/// fails. | |
@available(tvOS, unavailable) | |
public var maximumDistance: CGFloat | |
/// Creates a long-press gesture with a minimum duration and a maximum | |
/// distance that the interaction can move before the gesture fails. | |
/// | |
/// - Parameters: | |
/// - minimumDuration: The minimum duration of the long press that must | |
/// elapse before the gesture succeeds. | |
/// - maximumDistance: The maximum distance that the fingers or cursor | |
/// performing the long press can move before the gesture fails. | |
@available(tvOS, unavailable) | |
public init(minimumDuration: Double = 0.5, maximumDistance: CGFloat = 10) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
/// The type representing the gesture's value. | |
public typealias Value = Bool | |
} | |
/// A gesture that recognizes a magnification motion and tracks the amount of | |
/// magnification. | |
/// | |
/// A magnification gesture tracks how a magnification event sequence changes. | |
/// To recognize a magnification gesture on a view, create and configure the | |
/// gesture, and then add it to the view using the | |
/// ``View/gesture(_:including:)`` modifier. | |
/// | |
/// Add a magnification gesture to a ``Circle`` that changes its size while the | |
/// user performs the gesture: | |
/// | |
/// struct MagnificationGestureView: View { | |
/// | |
/// @GestureState var magnifyBy = CGFloat(1.0) | |
/// | |
/// var magnification: some Gesture { | |
/// MagnificationGesture() | |
/// .updating($magnifyBy) { currentState, gestureState, transaction in | |
/// gestureState = currentState | |
/// } | |
/// } | |
/// | |
/// var body: some View { | |
/// Circle() | |
/// .frame(width: 100 * magnifyBy, | |
/// height: 100 * magnifyBy, | |
/// alignment: .center) | |
/// .gesture(magnification) | |
/// } | |
/// } | |
/// | |
/// The circle's size resets to its original size when the gesture finishes. | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(watchOS, unavailable) | |
@available(tvOS, unavailable) | |
public struct MagnificationGesture : Gesture { | |
/// The minimum required delta before the gesture starts. | |
public var minimumScaleDelta: CGFloat | |
/// Creates a magnification gesture with a given minimum delta for the | |
/// gesture to start. | |
/// | |
/// - Parameter minimumScaleDelta: The minimum scale delta required before | |
/// the gesture starts. | |
public init(minimumScaleDelta: CGFloat = 0.01) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
/// The type representing the gesture's value. | |
public typealias Value = CGFloat | |
} | |
/// A set of view properties that may be synchronized between views | |
/// using the `View.matchedGeometryEffect()` function. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@frozen public struct MatchedGeometryProperties : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt32) | |
/// The view's position, in window coordinates. | |
public static let position: MatchedGeometryProperties | |
/// The view's size, in local coordinates. | |
public static let size: MatchedGeometryProperties | |
/// Both the `position` and `size` properties. | |
public static let frame: MatchedGeometryProperties | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = MatchedGeometryProperties | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = MatchedGeometryProperties | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension MatchedGeometryProperties : Sendable { | |
} | |
/// A background material type. | |
/// | |
/// You can apply a blur effect to a view that appears behind another view by | |
/// adding a material with the ``View/background(_:ignoresSafeAreaEdges:)`` | |
/// modifier: | |
/// | |
/// ZStack { | |
/// Color.teal | |
/// Label("Flag", systemImage: "flag.fill") | |
/// .padding() | |
/// .background(.regularMaterial) | |
/// } | |
/// | |
/// In the example above, the ``ZStack`` layers a ``Label`` on top of the color | |
/// ``ShapeStyle/teal``. The background modifier inserts the | |
/// regular material below the label, blurring the part of | |
/// the background that the label --- including its padding --- covers: | |
/// | |
/// ![A screenshot of a label on a teal background, where the area behind | |
/// the label appears blurred.](Material-1) | |
/// | |
/// A material isn't a view, but adding a material is like inserting a | |
/// translucent layer between the modified view and its background: | |
/// | |
/// ![An illustration that shows a background layer below a material layer, | |
/// which in turn appears below a foreground layer.](Material-2) | |
/// | |
/// The blurring effect provided by the material isn't simple opacity. Instead, | |
/// it uses a platform-specific blending that produces an effect that resembles | |
/// heavily frosted glass. You can see this more easily with a complex | |
/// background, like an image: | |
/// | |
/// ZStack { | |
/// Image("chili_peppers") | |
/// .resizable() | |
/// .aspectRatio(contentMode: .fit) | |
/// Label("Flag", systemImage: "flag.fill") | |
/// .padding() | |
/// .background(.regularMaterial) | |
/// } | |
/// | |
/// ![A screenshot of a label on an image background, where the area behind | |
/// the label appears blurred.](Material-3) | |
/// | |
/// For physical materials, the degree to which the background colors pass | |
/// through depends on the thickness. The effect also varies with light and | |
/// dark appearance: | |
/// | |
/// ![An array of labels on a teal background. The first column, labeled light | |
/// appearance, shows a succession of labels on blurred backgrounds where the | |
/// blur increases from top to bottom, resulting in lighter and lighter blur. | |
/// The second column, labeled dark appearance, shows a similar succession of | |
/// labels, except that the blur gets darker from top to bottom. The rows are | |
/// labeled, from top to bottom: no material, ultra thin, thin, regular, thick, | |
/// and ultra thick.](Material-4) | |
/// | |
/// If you need a material to have a particular shape, you can use the | |
/// ``View/background(_:in:fillStyle:)-20tq5`` modifier. For example, you can | |
/// create a material with rounded corners: | |
/// | |
/// ZStack { | |
/// Color.teal | |
/// Label("Flag", systemImage: "flag.fill") | |
/// .padding() | |
/// .background(.regularMaterial, in: RoundedRectangle(cornerRadius: 8)) | |
/// } | |
/// | |
/// ![A screenshot of a label on a teal background, where the area behind | |
/// the label appears blurred. The blurred area has rounded corners.](Material-5) | |
/// | |
/// When you add a material, foreground elements exhibit vibrancy, | |
/// a context-specific blend of the foreground and background colors | |
/// that improves contrast. However using ``View/foregroundStyle(_:)`` | |
/// to set a custom foreground style --- excluding the hierarchical | |
/// styles, like ``ShapeStyle/secondary`` --- disables vibrancy. | |
/// | |
/// > Note: A material blurs a background that's part of your app, but not | |
/// what appears behind your app on the screen. | |
/// For example, the content on the Home Screen doesn't affect the appearance | |
/// of a widget. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct Material { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *) | |
@available(watchOS, unavailable) | |
extension Material { | |
/// A material that's somewhat translucent. | |
public static let regular: Material | |
/// A material that's more opaque than translucent. | |
public static let thick: Material | |
/// A material that's more translucent than opaque. | |
public static let thin: Material | |
/// A mostly translucent material. | |
public static let ultraThin: Material | |
/// A mostly opaque material. | |
public static let ultraThick: Material | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Material { | |
/// A material matching the style of system toolbars. | |
public static let bar: Material | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Material : ShapeStyle { | |
} | |
/// A control for presenting a menu of actions. | |
/// | |
/// The following example presents a menu of three buttons and a submenu, which | |
/// contains three buttons of its own. | |
/// | |
/// Menu("Actions") { | |
/// Button("Duplicate", action: duplicate) | |
/// Button("Rename", action: rename) | |
/// Button("Delete…", action: delete) | |
/// Menu("Copy") { | |
/// Button("Copy", action: copy) | |
/// Button("Copy Formatted", action: copyFormatted) | |
/// Button("Copy Library Path", action: copyPath) | |
/// } | |
/// } | |
/// | |
/// You can create the menu's title with a ``LocalizedStringKey``, as seen in | |
/// the previous example, or with a view builder that creates multiple views, | |
/// such as an image and a text view: | |
/// | |
/// Menu { | |
/// Button("Open in Preview", action: openInPreview) | |
/// Button("Save as PDF", action: saveAsPDF) | |
/// } label: { | |
/// Label("PDF", systemImage: "doc.fill") | |
/// } | |
/// | |
/// ### Primary Action | |
/// | |
/// Menus can be created with a custom primary action. The primary action will | |
/// be performed when the user taps or clicks on the body of the control, and | |
/// the menu presentation will happen on a secondary gesture, such as on | |
/// long press or on click of the menu indicator. The following example creates | |
/// a menu that adds bookmarks, with advanced options that are presented in a | |
/// menu. | |
/// | |
/// Menu { | |
/// Button(action: addCurrentTabToReadingList) { | |
/// Label("Add to Reading List", systemImage: "eyeglasses") | |
/// } | |
/// Button(action: bookmarkAll) { | |
/// Label("Add Bookmarks for All Tabs", systemImage: "book") | |
/// } | |
/// Button(action: show) { | |
/// Label("Show All Bookmarks", systemImage: "books.vertical") | |
/// } | |
/// } label: { | |
/// Label("Add Bookmark", systemImage: "book") | |
/// } primaryAction: { | |
/// addBookmark() | |
/// } | |
/// | |
/// ### Styling Menus | |
/// | |
/// Use the ``View/menuStyle(_:)`` modifier to change the style of all menus | |
/// in a view. The following example shows how to apply a custom style: | |
/// | |
/// Menu("Editing") { | |
/// Button("Set In Point", action: setInPoint) | |
/// Button("Set Out Point", action: setOutPoint) | |
/// } | |
/// .menuStyle(EditingControlsMenuStyle()) | |
/// | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct Menu<Label, Content> : View where Label : View, Content : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Menu { | |
/// Creates a menu with a custom label. | |
/// | |
/// - Parameters: | |
/// - content: A group of menu items. | |
/// - label: A view describing the content of the menu. | |
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) | |
/// Creates a menu that generates its label from a localized string key. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the link's localized title, which describes | |
/// the contents of the menu. | |
/// - content: A group of menu items. | |
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content) where Label == Text | |
/// Creates a menu that generates its label from a string. | |
/// | |
/// To create the label with a localized string key, use | |
/// ``Menu/init(_:content:)-7v768`` instead. | |
/// | |
/// - Parameters: | |
/// - title: A string that describes the contents of the menu. | |
/// - content: A group of menu items. | |
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where Label == Text, S : StringProtocol | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Menu { | |
/// Creates a menu with a custom primary action and custom label. | |
/// | |
/// - Parameters: | |
/// - content: A group of menu items. | |
/// - label: A view describing the content of the menu. | |
/// - primaryAction: The action to perform on primary | |
/// interaction with the menu. | |
public init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label, primaryAction: @escaping () -> Void) | |
/// Creates a menu with a custom primary action that generates its label | |
/// from a localized string key. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the link's localized title, which describes | |
/// the contents of the menu. | |
/// - primaryAction: The action to perform on primary | |
/// interaction with the menu. | |
/// - content: A group of menu items. | |
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content, primaryAction: @escaping () -> Void) where Label == Text | |
/// Creates a menu with a custom primary action that generates its label | |
/// from a string. | |
/// | |
/// To create the label with a localized string key, use | |
/// `Menu(_:primaryAction:content:)` instead. | |
/// | |
/// - Parameters: | |
/// - title: A string that describes the contents of the menu. | |
/// - primaryAction: The action to perform on primary | |
/// interaction with the menu. | |
/// - content: A group of menu items. | |
public init<S>(_ title: S, @ViewBuilder content: () -> Content, primaryAction: @escaping () -> Void) where Label == Text, S : StringProtocol | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Menu where Label == MenuStyleConfiguration.Label, Content == MenuStyleConfiguration.Content { | |
/// Creates a menu based on a style configuration. | |
/// | |
/// Use this initializer within the ``MenuStyle/makeBody(configuration:)`` | |
/// method of a ``MenuStyle`` instance to create an instance of the menu | |
/// being styled. This is useful for custom menu styles that modify the | |
/// current menu style. | |
/// | |
/// For example, the following code creates a new, custom style that adds a | |
/// red border around the current menu style: | |
/// | |
/// struct RedBorderMenuStyle: MenuStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// Menu(configuration) | |
/// .border(Color.red) | |
/// } | |
/// } | |
/// | |
public init(_ configuration: MenuStyleConfiguration) | |
} | |
/// A picker style that presents the options as a menu when the user presses a | |
/// button, or as a submenu when nested within a larger menu. | |
/// | |
/// Do not use this type directly. Instead, use ``PickerStyle/menu``. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct MenuPickerStyle : PickerStyle { | |
/// Creates a menu picker style. | |
public init() | |
} | |
/// A type that applies standard interaction behavior and a custom appearance | |
/// to all menus within a view hierarchy. | |
/// | |
/// To configure the current menu style for a view hierarchy, use the | |
/// ``View/menuStyle(_:)`` modifier. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public protocol MenuStyle { | |
/// A view that represents the body of a menu. | |
associatedtype Body : View | |
/// Creates a view that represents the body of a menu. | |
/// | |
/// - Parameter configuration: The properties of the menu. | |
/// | |
/// The system calls this method for each ``Menu`` instance in a view | |
/// hierarchy where this style is the current menu style. | |
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body | |
/// The properties of a menu. | |
typealias Configuration = MenuStyleConfiguration | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension MenuStyle where Self == DefaultMenuStyle { | |
/// The default menu style, based on the menu's context. | |
/// | |
/// The default menu style can vary by platform. By default, macOS uses the | |
/// bordered button style. | |
/// | |
/// If you create a menu inside a container, the style resolves to the | |
/// recommended style for menus inside that container for that specific | |
/// platform. For example, a menu nested within another menu will resolve to | |
/// a submenu: | |
/// | |
/// Menu("Edit") { | |
/// Menu("Arrange") { | |
/// Button("Bring to Front", action: moveSelectionToFront) | |
/// Button("Send to Back", action: moveSelectionToBack) | |
/// } | |
/// Button("Delete", action: deleteSelection) | |
/// } | |
/// | |
/// You can override a menu's style. To apply the default style to a menu, | |
/// or to a view that contains a menu, use the ``View/menuStyle(_:)`` | |
/// modifier. | |
public static var automatic: DefaultMenuStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension MenuStyle where Self == BorderlessButtonMenuStyle { | |
/// A menu style that displays a borderless button that toggles the display of | |
/// the menu's contents when pressed. | |
/// | |
/// On macOS, the button optionally displays an arrow indicating that it | |
/// presents a menu. | |
/// | |
/// Pressing and then dragging into the contents triggers the chosen action on | |
/// release. | |
public static var borderlessButton: BorderlessButtonMenuStyle { get } | |
} | |
/// A configuration of a menu. | |
/// | |
/// Use the ``Menu/init(_:)`` initializer of ``Menu`` to create an | |
/// instance using the current menu style, which you can modify to create a | |
/// custom style. | |
/// | |
/// For example, the following code creates a new, custom style that adds a red | |
/// border to the current menu style: | |
/// | |
/// struct RedBorderMenuStyle: MenuStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// Menu(configuration) | |
/// .border(Color.red) | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct MenuStyleConfiguration { | |
/// A type-erased label of a menu. | |
public struct Label : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A type-erased content of a menu. | |
public struct Content : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
} | |
/// A value with a modifier applied to it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct ModifiedContent<Content, Modifier> { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
/// The content that the modifier transforms into a new view or new | |
/// view modifier. | |
public var content: Content | |
/// The view modifier. | |
public var modifier: Modifier | |
/// A structure that the defines the content and modifier needed to produce | |
/// a new view or view modifier. | |
/// | |
/// If `content` is a ``View`` and `modifier` is a ``ViewModifier``, the | |
/// result is a ``View``. If `content` and `modifier` are both view | |
/// modifiers, then the result is a new ``ViewModifier`` combining them. | |
/// | |
/// - Parameters: | |
/// - content: The content that the modifier changes. | |
/// - modifier: The modifier to apply to the content. | |
@inlinable public init(content: Content, modifier: Modifier) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds an accessibility action to the view. Actions allow assistive technologies, | |
/// such as the VoiceOver, to interact with the view by invoking the action. | |
/// | |
/// For example, this is how a `.default` action to compose | |
/// a new email could be added to a view. | |
/// | |
/// var body: some View { | |
/// ContentView() | |
/// .accessibilityAction { | |
/// // Handle action | |
/// } | |
/// } | |
/// | |
public func accessibilityAction(_ actionKind: AccessibilityActionKind = .default, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier> | |
/// Adds an accessibility action to the view. Actions allow assistive technologies, | |
/// such as the VoiceOver, to interact with the view by invoking the action. | |
/// | |
/// For example, this is how a custom action to compose | |
/// a new email could be added to a view. | |
/// | |
/// var body: some View { | |
/// ContentView() | |
/// .accessibilityAction(named: Text("New Message")) { | |
/// // Handle action | |
/// } | |
/// } | |
/// | |
public func accessibilityAction(named name: Text, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds an accessibility action to the view. Actions allow assistive technologies, | |
/// such as the VoiceOver, to interact with the view by invoking the action. | |
/// | |
/// For example, this is how a custom action to compose | |
/// a new email could be added to a view. | |
/// | |
/// var body: some View { | |
/// ContentView() | |
/// .accessibilityAction(named: "New Message") { | |
/// // Handle action | |
/// } | |
/// } | |
/// | |
public func accessibilityAction(named nameKey: LocalizedStringKey, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier> | |
/// Adds an accessibility action to the view. Actions allow assistive technologies, | |
/// such as the VoiceOver, to interact with the view by invoking the action. | |
/// | |
/// For example, this is how a custom action to compose | |
/// a new email could be added to a view. | |
/// | |
/// var body: some View { | |
/// ContentView() | |
/// .accessibilityAction(named: "New Message") { | |
/// // Handle action | |
/// } | |
/// } | |
/// | |
public func accessibilityAction<S>(named name: S, _ handler: @escaping () -> Void) -> ModifiedContent<Content, Modifier> where S : StringProtocol | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent : Equatable where Content : Equatable, Modifier : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: ModifiedContent<Content, Modifier>, b: ModifiedContent<Content, Modifier>) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent : View where Content : View, Modifier : ViewModifier { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: ModifiedContent<Content, Modifier>.Body { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent : ViewModifier where Content : ViewModifier, Modifier : ViewModifier { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent : DynamicViewContent where Content : DynamicViewContent, Modifier : ViewModifier { | |
/// The collection of underlying data. | |
public var data: Content.Data { get } | |
/// The type of the underlying collection of data. | |
public typealias Data = Content.Data | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example, `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter key: Key used to specify the identifier and label of the | |
/// of the additional accessibility information entry. | |
/// - Parameter value: Text value for the additional accessibility | |
/// information. For example: "landscape." A value of `nil` will remove | |
/// any entry of additional information added earlier for any `key` with | |
/// the same identifier. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s | |
/// having different identifiers will create new entries of | |
/// additional information. | |
/// Calling `accessibilityAdditionalContent` repeatedly with `key`s | |
/// having matching identifiers will replace the previous entry. | |
public func accessibilityCustomContent(_ key: AccessibilityCustomContentKey, _ value: Text?, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example, `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter key: Key used to specify the identifier and label of the | |
/// of the additional accessibility information entry. | |
/// - Parameter valueKey: Text value for the additional accessibility | |
/// information. For example: "landscape." A value of `nil` will remove | |
/// any entry of additional information added earlier for any `key` with | |
/// the same identifier. | |
/// - Parameter importance: Importance of the accessibility information. | |
/// High-importance information gets read out immediately, while | |
/// default-importance information must be explicitly asked for by the | |
/// user. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s | |
/// having different identifiers will create new entries of | |
/// additional information. | |
/// Calling `accessibilityAdditionalContent` repeatedly with `key`s | |
/// having matching identifiers will replace the previous entry. | |
public func accessibilityCustomContent(_ key: AccessibilityCustomContentKey, _ valueKey: LocalizedStringKey, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example, `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter key: Key used to specify the identifier and label of the | |
/// of the additional accessibility information entry. | |
/// - Parameter value: Text value for the additional accessibility | |
/// information. For example: "landscape." A value of `nil` will remove | |
/// any entry of additional information added earlier for any `key` with | |
/// the same identifier. | |
/// - Parameter importance: Importance of the accessibility information. | |
/// High-importance information gets read out immediately, while | |
/// default-importance information must be explicitly asked for by the | |
/// user. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with `key`s | |
/// having different identifiers will create new entries of | |
/// additional information. | |
/// Calling `accessibilityAdditionalContent` repeatedly with `key`s | |
/// having matching identifiers will replace the previous entry. | |
public func accessibilityCustomContent<V>(_ key: AccessibilityCustomContentKey, _ value: V, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> where V : StringProtocol | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example: `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter label: Localized text describing to the user what | |
/// is contained in this additional information entry. For example: | |
/// "orientation". | |
/// - Parameter value: Text value for the additional accessibility | |
/// information. For example: "landscape." | |
/// - Parameter importance: Importance of the accessibility information. | |
/// High-importance information gets read out immediately, while | |
/// default-importance information must be explicitly asked for by the | |
/// user. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with different | |
/// labels will create new entries of additional information. Calling | |
/// `accessibilityAdditionalContent` repeatedly with the same label will | |
/// instead replace the previous value and importance. | |
public func accessibilityCustomContent(_ label: Text, _ value: Text, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example: `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter label: Localized text describing to the user what | |
/// is contained in this additional information entry. For example: | |
/// "orientation". | |
/// - Parameter value: Text value for the additional accessibility | |
/// information. For example: "landscape." | |
/// - Parameter importance: Importance of the accessibility information. | |
/// High-importance information gets read out immediately, while | |
/// default-importance information must be explicitly asked for by the | |
/// user. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with different | |
/// labels will create new entries of additional information. Calling | |
/// `accessibilityAdditionalContent` repeatedly with the same label will | |
/// instead replace the previous value and importance. | |
public func accessibilityCustomContent(_ labelKey: LocalizedStringKey, _ value: Text, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example, `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter labelKey: Localized text describing to the user what | |
/// is contained in this additional information entry. For example: | |
/// "orientation". | |
/// - Parameter value: Text value for the additional accessibility | |
/// information. For example: "landscape." | |
/// - Parameter importance: Importance of the accessibility information. | |
/// High-importance information gets read out immediately, while | |
/// default-importance information must be explicitly asked for by the | |
/// user. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with different | |
/// labels will create new entries of additional information. Calling | |
/// `accessibilityAdditionalContent` repeatedly with the same label will | |
/// instead replace the previous value and importance. | |
public func accessibilityCustomContent(_ labelKey: LocalizedStringKey, _ valueKey: LocalizedStringKey, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> | |
/// Add additional accessibility information to the view. | |
/// | |
/// Use this method to add information you want accessibility users to be | |
/// able to access about this element, beyond the basics of label, value, | |
/// and hint. For example, `accessibilityCustomContent` can be used to add | |
/// information about the orientation of a photograph, or the number of | |
/// people found in the picture. | |
/// | |
/// - Parameter labelKey: Localized text describing to the user what | |
/// is contained in this additional information entry. For example: | |
/// "orientation". | |
/// - Parameter value: Text value for the additional accessibility | |
/// information. For example: "landscape." | |
/// - Parameter importance: Importance of the accessibility information. | |
/// High-importance information gets read out immediately, while | |
/// default-importance information must be explicitly asked for by the | |
/// user. | |
/// - Note: Repeated calls of `accessibilityCustomContent` with different | |
/// labels will create new entries of additional information. Calling | |
/// `accessibilityAdditionalContent` repeatedly with the same label will | |
/// instead replace the previous value and importance. | |
public func accessibilityCustomContent<V>(_ labelKey: LocalizedStringKey, _ value: V, importance: AXCustomContent.Importance = .default) -> ModifiedContent<Content, Modifier> where V : StringProtocol | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Specifies whether to hide this view from system accessibility features. | |
public func accessibilityHidden(_ hidden: Bool) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent : Scene where Content : Scene, Modifier : _SceneModifier { | |
/// The content and behavior of the scene. | |
/// | |
/// For any scene that you create, provide a computed `body` property that | |
/// defines the scene as a composition of other scenes. You can assemble a | |
/// scene from primitive scenes that SwiftUI provides, as well as other | |
/// scenes that you've defined. | |
/// | |
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype`` | |
/// associated type based on the contents of the `body` property. | |
public var body: ModifiedContent<Content, Modifier>.Body { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Explicitly set whether this Accessibility element responds to user | |
/// interaction and would thus be interacted with by technologies such as | |
/// Switch Control, Voice Control or Full Keyboard Access. | |
/// | |
/// If this is not set, the value is inferred from the traits of the | |
/// Accessibility element, the presence of Accessibility actions on the | |
/// element, or the presence of gestures on the element or containing views. | |
public func accessibilityRespondsToUserInteraction(_ respondsToUserInteraction: Bool = true) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon. | |
/// For example, you could use this method to label a button that plays music with the text "Play". | |
/// Don't include text in the label that repeats information that users already have. For example, | |
/// don't use the label "Play button" because a button already has a trait that identifies it as a button. | |
public func accessibilityLabel(_ label: Text) -> ModifiedContent<Content, Modifier> | |
/// Communicates to the user what happens after performing the view's | |
/// action. | |
/// | |
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or | |
/// "Downloads the attachment". | |
public func accessibilityHint(_ hint: Text) -> ModifiedContent<Content, Modifier> | |
/// Sets alternate input labels with which users identify a view. | |
/// | |
/// If you don't specify any input labels, the user can still refer to the view using the accessibility | |
/// label that you add with the accessibilityLabel() modifier. Provide labels in descending order | |
/// of importance. Voice Control and Full Keyboard Access use the input labels. | |
public func accessibilityInputLabels(_ inputLabels: [Text]) -> ModifiedContent<Content, Modifier> | |
/// Uses the string you specify to identify the view. | |
/// | |
/// Use this value for testing. It isn't visible to the user. | |
public func accessibilityIdentifier(_ identifier: String) -> ModifiedContent<Content, Modifier> | |
/// Specifies the point where activations occur in the view. | |
public func accessibilityActivationPoint(_ activationPoint: CGPoint) -> ModifiedContent<Content, Modifier> | |
/// Specifies the unit point where activations occur in the view. | |
public func accessibilityActivationPoint(_ activationPoint: UnitPoint) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon. | |
/// For example, you could use this method to label a button that plays music with the text "Play". | |
/// Don't include text in the label that repeats information that users already have. For example, | |
/// don't use the label "Play button" because a button already has a trait that identifies it as a button. | |
public func accessibilityLabel(_ labelKey: LocalizedStringKey) -> ModifiedContent<Content, Modifier> | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon. | |
/// For example, you could use this method to label a button that plays music with the text "Play". | |
/// Don't include text in the label that repeats information that users already have. For example, | |
/// don't use the label "Play button" because a button already has a trait that identifies it as a button. | |
public func accessibilityLabel<S>(_ label: S) -> ModifiedContent<Content, Modifier> where S : StringProtocol | |
/// Communicates to the user what happens after performing the view's | |
/// action. | |
/// | |
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or | |
/// "Downloads the attachment". | |
public func accessibilityHint(_ hintKey: LocalizedStringKey) -> ModifiedContent<Content, Modifier> | |
/// Communicates to the user what happens after performing the view's | |
/// action. | |
/// | |
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or | |
/// "Downloads the attachment". | |
public func accessibilityHint<S>(_ hint: S) -> ModifiedContent<Content, Modifier> where S : StringProtocol | |
/// Sets alternate input labels with which users identify a view. | |
/// | |
/// Provide labels in descending order of importance. Voice Control | |
/// and Full Keyboard Access use the input labels. | |
/// | |
/// > Note: If you don't specify any input labels, the user can still | |
/// refer to the view using the accessibility label that you add with the | |
/// `accessibilityLabel()` modifier. | |
public func accessibilityInputLabels(_ inputLabelKeys: [LocalizedStringKey]) -> ModifiedContent<Content, Modifier> | |
/// Sets alternate input labels with which users identify a view. | |
/// | |
/// Provide labels in descending order of importance. Voice Control | |
/// and Full Keyboard Access use the input labels. | |
/// | |
/// > Note: If you don't specify any input labels, the user can still | |
/// refer to the view using the accessibility label that you add with the | |
/// `accessibilityLabel()` modifier. | |
public func accessibilityInputLabels<S>(_ inputLabels: [S]) -> ModifiedContent<Content, Modifier> where S : StringProtocol | |
} | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Specifies whether to hide this view from system accessibility features. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHidden(_:)") | |
public func accessibility(hidden: Bool) -> ModifiedContent<Content, Modifier> | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an accessibility label for a view that doesn't display text, like an icon. | |
/// For example, you could use this method to label a button that plays music with the text "Play". | |
/// Don't include text in the label that repeats information that users already have. For example, | |
/// don't use the label "Play button" because a button already has a trait that identifies it as a button. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityLabel(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityLabel(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityLabel(_:)") | |
public func accessibility(label: Text) -> ModifiedContent<Content, Modifier> | |
/// Communicates to the user what happens after performing the view's | |
/// action. | |
/// | |
/// Provide a hint in the form of a brief phrase, like "Purchases the item" or | |
/// "Downloads the attachment". | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityHint(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityHint(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityHint(_:)") | |
public func accessibility(hint: Text) -> ModifiedContent<Content, Modifier> | |
/// Sets alternate input labels with which users identify a view. | |
/// | |
/// If you don't specify any input labels, the user can still refer to the view using the accessibility | |
/// label that you add with the accessibilityLabel() modifier. Provide labels in descending order | |
/// of importance. Voice Control and Full Keyboard Access use the input labels. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityInputLabels(_:)") | |
public func accessibility(inputLabels: [Text]) -> ModifiedContent<Content, Modifier> | |
/// Uses the specified string to identify the view. | |
/// | |
/// Use this value for testing. It isn't visible to the user. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityIdentifier(_:)") | |
public func accessibility(identifier: String) -> ModifiedContent<Content, Modifier> | |
@available(iOS, deprecated, introduced: 13.0) | |
@available(macOS, deprecated, introduced: 10.15) | |
@available(tvOS, deprecated, introduced: 13.0) | |
@available(watchOS, deprecated, introduced: 6) | |
public func accessibility(selectionIdentifier: AnyHashable) -> ModifiedContent<Content, Modifier> | |
/// Sets the sort priority order for this view's accessibility | |
/// element, relative to other elements at the same level. | |
/// | |
/// Higher numbers are sorted first. The default sort priority is zero. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilitySortPriority(_:)") | |
public func accessibility(sortPriority: Double) -> ModifiedContent<Content, Modifier> | |
/// Specifies the point where activations occur in the view. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
public func accessibility(activationPoint: CGPoint) -> ModifiedContent<Content, Modifier> | |
/// Specifies the unit point where activations occur in the view. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityActivationPoint(_:)") | |
public func accessibility(activationPoint: UnitPoint) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Sets the sort priority order for this view's accessibility | |
/// element, relative to other elements at the same level. | |
/// | |
/// Higher numbers are sorted first. The default sort priority is zero. | |
public func accessibilitySortPriority(_ sortPriority: Double) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds the given traits to the view. | |
public func accessibilityAddTraits(_ traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier> | |
/// Removes the given traits from this view. | |
public func accessibilityRemoveTraits(_ traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier> | |
} | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds the given traits to the view. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityAddTraits(_:)") | |
public func accessibility(addTraits traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier> | |
/// Removes the given traits from this view. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityRemoveTraits(_:)") | |
public func accessibility(removeTraits traits: AccessibilityTraits) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds an accessibility scroll action to the view. Actions allow | |
/// assistive technologies, such as the VoiceOver, to interact with the | |
/// view by invoking the action. | |
/// | |
/// For example, this is how a scroll action to trigger | |
/// a refresh could be added to a view. | |
/// | |
/// var body: some View { | |
/// ScrollView { | |
/// ContentView() | |
/// } | |
/// .accessibilityScrollAction { edge in | |
/// if edge == .top { | |
/// // Refresh content | |
/// } | |
/// } | |
/// } | |
/// | |
public func accessibilityScrollAction(_ handler: @escaping (Edge) -> Void) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds an accessibility adjustable action to the view. Actions allow | |
/// assistive technologies, such as the VoiceOver, to interact with the | |
/// view by invoking the action. | |
/// | |
/// For example, this is how an adjustable action to navigate | |
/// through pages could be added to a view. | |
/// | |
/// var body: some View { | |
/// PageControl() | |
/// .accessibilityAdjustableAction { direction in | |
/// switch direction { | |
/// case .increment: | |
/// // Go to next page | |
/// case .decrement: | |
/// // Go to previous page | |
/// } | |
/// } | |
/// } | |
/// | |
public func accessibilityAdjustableAction(_ handler: @escaping (AccessibilityAdjustmentDirection) -> Void) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Sets an accessibility text content type. | |
/// | |
/// Use this modifier to set the content type of this accessibility | |
/// element. Assistive technologies can use this property to choose | |
/// an appropriate way to output the text. For example, when | |
/// encountering a source coding context, VoiceOver could | |
/// choose to speak all punctuation. | |
/// | |
/// The default content type ``AccessibilityTextContentType/plain``. | |
/// | |
/// - Parameter value: The accessibility content type from the available | |
/// ``AccessibilityTextContentType`` options. | |
public func accessibilityTextContentType(_ textContentType: AccessibilityTextContentType) -> ModifiedContent<Content, Modifier> | |
/// Set the level of this heading. | |
/// | |
/// Use this modifier to set the level of this heading in relation to other headings. The system speaks | |
/// the level number of levels ``AccessibilityHeadingLevel/h1`` | |
/// through ``AccessibilityHeadingLevel/h6`` alongside the text. | |
/// | |
/// The default heading level if you don’t use this modifier | |
/// is ``AccessibilityHeadingLevel/unspecified``. | |
/// | |
/// - Parameter level: The heading level to associate with this element | |
/// from the available ``AccessibilityHeadingLevel`` levels. | |
public func accessibilityHeading(_ level: AccessibilityHeadingLevel) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds a textual description of the value that the view contains. | |
/// | |
/// Use this method to describe the value represented by a view, but only if that's different than the | |
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(), | |
/// you can provide the current volume setting, like "60%", using accessibilityValue(). | |
public func accessibilityValue(_ valueDescription: Text) -> ModifiedContent<Content, Modifier> | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds a textual description of the value that the view contains. | |
/// | |
/// Use this method to describe the value represented by a view, but only if that's different than the | |
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(), | |
/// you can provide the current volume setting, like "60%", using accessibilityValue(). | |
public func accessibilityValue(_ valueKey: LocalizedStringKey) -> ModifiedContent<Content, Modifier> | |
/// Adds a textual description of the value that the view contains. | |
/// | |
/// Use this method to describe the value represented by a view, but only if that's different than the | |
/// view's label. For example, for a slider that you label as "Volume" using accessibilityLabel(), | |
/// you can provide the current volume setting, like "60%", using accessibilityValue(). | |
public func accessibilityValue<S>(_ value: S) -> ModifiedContent<Content, Modifier> where S : StringProtocol | |
} | |
extension ModifiedContent where Modifier == AccessibilityAttachmentModifier { | |
/// Adds a textual description of the value that the view contains. | |
/// | |
/// Use this method to describe the value represented by a view, but only if that's different than the | |
/// view's label. For example, for a slider that you label as "Volume" using accessibility(label:), | |
/// you can provide the current volume setting, like "60%", using accessibility(value:). | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "accessibilityValue(_:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "accessibilityValue(_:)") | |
@available(watchOS, introduced: 6, deprecated: 100000.0, renamed: "accessibilityValue(_:)") | |
public func accessibility(value: Text) -> ModifiedContent<Content, Modifier> | |
} | |
/// A dynamic property type that allows access to a namespace defined | |
/// by the persistent identity of the object containing the property | |
/// (e.g. a view). | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@frozen @propertyWrapper public struct Namespace : DynamicProperty { | |
@inlinable public init() | |
public var wrappedValue: Namespace.ID { get } | |
/// A namespace defined by the persistent identity of an | |
/// `@Namespace` dynamic property. | |
@frozen public struct ID : Hashable { | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Namespace.ID, b: Namespace.ID) -> Bool | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Namespace : Sendable { | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Namespace.ID : Sendable { | |
} | |
/// A configuration for a navigation bar that represents a view at the top of a | |
/// navigation stack. | |
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
@available(macOS, unavailable) | |
public struct NavigationBarItem { | |
/// A style for displaying the title of a navigation bar. | |
public enum TitleDisplayMode { | |
/// Inherit the display mode from the previous navigation item. | |
case automatic | |
/// Display the title within the standard bounds of the navigation bar. | |
case inline | |
/// Display a large title within an expanded navigation bar. | |
@available(watchOS 8.0, *) | |
@available(tvOS, unavailable) | |
case large | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: NavigationBarItem.TitleDisplayMode, b: NavigationBarItem.TitleDisplayMode) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
@available(macOS, unavailable) | |
extension NavigationBarItem.TitleDisplayMode : Equatable { | |
} | |
@available(iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
@available(macOS, unavailable) | |
extension NavigationBarItem.TitleDisplayMode : Hashable { | |
} | |
/// The navigation control group style. | |
/// | |
/// Do not use this type directly. Instead, use | |
/// ``ControlGroupStyle/navigation``. | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct NavigationControlGroupStyle : ControlGroupStyle { | |
/// Creates a navigation control group style. | |
@available(iOS, introduced: 15.0, deprecated: 15.0, message: "Use `.navigation` instead.") | |
@available(macOS, introduced: 12.0, deprecated: 12.0, message: "Use `.navigation` instead.") | |
public init() | |
/// Creates a view representing the body of a control group. | |
/// | |
/// - Parameter configuration: The properties of the control group instance | |
/// being created. | |
/// | |
/// This method will be called for each instance of ``ControlGroup`` created | |
/// within a view hierarchy where this style is the current | |
/// `ControlGroupStyle`. | |
public func makeBody(configuration: NavigationControlGroupStyle.Configuration) -> some View | |
/// A view representing the body of a control group. | |
public typealias Body = some View | |
} | |
/// A view that controls a navigation presentation. | |
/// | |
/// Users click or tap a navigation link to present a view inside a | |
/// ``NavigationView``. You control the visual appearance of the link by | |
/// providing view content in the link's trailing closure. For | |
/// example, you can use a ``Label`` to display a link: | |
/// | |
/// NavigationLink(destination: FolderList(id: workFolder.id)) { | |
/// Label("Work Folder", systemImage: "folder") | |
/// } | |
/// | |
/// For a link composed only of text, you can use one of the convenience | |
/// initializers that takes a string and creates a ``Text`` view for you: | |
/// | |
/// NavigationLink("Work Folder", destination: FolderList(id: workFolder.id)) | |
/// | |
/// Perform navigation by initializing a link with a destination view. | |
/// For example, consider a `ColorDetail` view that displays a color sample: | |
/// | |
/// struct ColorDetail: View { | |
/// var color: Color | |
/// | |
/// var body: some View { | |
/// color | |
/// .frame(width: 200, height: 200) | |
/// .navigationTitle(color.description.capitalized) | |
/// } | |
/// } | |
/// | |
/// The following ``NavigationView`` presents three links to | |
/// color detail views: | |
/// | |
/// NavigationView { | |
/// List { | |
/// NavigationLink("Purple", destination: ColorDetail(color: .purple)) | |
/// NavigationLink("Pink", destination: ColorDetail(color: .pink)) | |
/// NavigationLink("Orange", destination: ColorDetail(color: .orange)) | |
/// } | |
/// .navigationTitle("Colors") | |
/// | |
/// Text("Select a Color") // A placeholder to show before selection. | |
/// } | |
/// | |
/// ![An iPad in landscape mode, showing a multicolumn navigation view. In | |
/// the left column, a list of three items, Purple, Pink, and Orange, with | |
/// the first selected. On the right, a detail view that shows a purple | |
/// square.](NavigationLink-1) | |
/// | |
/// Optionally, you can use a navigation link to perform navigation | |
/// programmatically. You do so in one of two ways: | |
/// * Bind the link's `isActive` parameter to a Boolean value. | |
/// Setting the value to `true` performs the navigation. | |
/// * Bind the link's `selection` parameter to a value and provide a `tag` of | |
/// the variable’s type. Setting the value of `selection` to `tag` performs | |
/// the navigation. | |
/// | |
/// For example, you can create a ``State`` variable that indicates when | |
/// the purple page in the previous example appears: | |
/// | |
/// @State private var shouldShowPurple = false | |
/// | |
/// Then you can modify the purple navigation link to bind to the state | |
/// variable: | |
/// | |
/// NavigationLink( | |
/// "Purple", | |
/// destination: ColorDetail(color: .purple), | |
/// isActive: $shouldShowPurple) | |
/// | |
/// If elsewhere in your code you set `shouldShowPurple` to `true`, the | |
/// navigation link activates. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct NavigationLink<Label, Destination> : View where Label : View, Destination : View { | |
/// Creates a navigation link that presents the destination view. | |
/// - Parameters: | |
/// - destination: A view for the navigation link to present. | |
/// - label: A view builder to produce a label describing the `destination` | |
/// to present. | |
public init(@ViewBuilder destination: () -> Destination, @ViewBuilder label: () -> Label) | |
/// Creates a navigation link that presents the destination view when active. | |
/// - Parameters: | |
/// - isActive: A binding to a Boolean value that indicates whether | |
/// `destination` is currently presented. | |
/// - destination: A view for the navigation link to present. | |
/// - label: A view builder to produce a label describing the `destination` | |
/// to present. | |
public init(isActive: Binding<Bool>, @ViewBuilder destination: () -> Destination, @ViewBuilder label: () -> Label) | |
/// Creates a navigation link that presents the destination view when | |
/// a bound selection variable equals a given tag value. | |
/// - Parameters: | |
/// - tag: The value of `selection` that causes the link to present | |
/// `destination`. | |
/// - selection: A bound variable that causes the link to present | |
/// `destination` when `selection` becomes equal to `tag`. | |
/// - destination: A view for the navigation link to present. | |
/// - label: A view builder to produce a label describing the | |
/// `destination` to present. | |
public init<V>(tag: V, selection: Binding<V?>, @ViewBuilder destination: () -> Destination, @ViewBuilder label: () -> Label) where V : Hashable | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// Creates a navigation link that presents the destination view. | |
/// - Parameters: | |
/// - destination: A view for the navigation link to present. | |
/// - label: A view builder to produce a label describing the `destination` | |
/// to present. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
public init(destination: Destination, @ViewBuilder label: () -> Label) | |
/// Creates a navigation link that presents the destination view when active. | |
/// - Parameters: | |
/// - destination: A view for the navigation link to present. | |
/// - isActive: A binding to a Boolean value that indicates whether | |
/// `destination` is currently presented. | |
/// - label: A view builder to produce a label describing the `destination` | |
/// to present. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(isActive:destination:label:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "NavigationLink(isActive:destination:label:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(isActive:destination:label:)") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "NavigationLink(isActive:destination:label:)") | |
public init(destination: Destination, isActive: Binding<Bool>, @ViewBuilder label: () -> Label) | |
/// Creates a navigation link that presents the destination view when | |
/// a bound selection variable equals a given tag value. | |
/// - Parameters: | |
/// - destination: A view for the navigation link to present. | |
/// - tag: The value of `selection` that causes the link to present | |
/// `destination`. | |
/// - selection: A bound variable that causes the link to present | |
/// `destination` when `selection` becomes equal to `tag`. | |
/// - label: A view builder to produce a label describing the | |
/// `destination` to present. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(tag:selection:destination:label:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "NavigationLink(tag:selection:destination:label:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(tag:selection:destination:label:)") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "NavigationLink(tag:selection:destination:label:)") | |
public init<V>(destination: Destination, tag: V, selection: Binding<V?>, @ViewBuilder label: () -> Label) where V : Hashable | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension NavigationLink where Label == Text { | |
/// Creates a navigation link that presents a destination view, with a text label | |
/// that the link generates from a localized string key. | |
/// - Parameters: | |
/// - titleKey: A localized string key for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
public init(_ titleKey: LocalizedStringKey, @ViewBuilder destination: () -> Destination) | |
/// Creates a navigation link that presents a destination view, with a text label | |
/// that the link generates from a title string. | |
/// - Parameters: | |
/// - title: A string for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
public init<S>(_ title: S, @ViewBuilder destination: () -> Destination) where S : StringProtocol | |
/// Creates a navigation link that presents a destination view when active, with a | |
/// text label that the link generates from a localized string key. | |
/// - Parameters: | |
/// - titleKey: A localized string key for creating a text label. | |
/// - isActive: A binding to a Boolean value that indicates whether | |
/// `destination` is currently presented. | |
/// - destination: A view for the navigation link to present. | |
public init(_ titleKey: LocalizedStringKey, isActive: Binding<Bool>, @ViewBuilder destination: () -> Destination) | |
/// Creates a navigation link that presents a destination view when active, with a | |
/// text label that the link generates from a title string. | |
/// - Parameters: | |
/// - title: A string for creating a text label. | |
/// - isActive: A binding to a Boolean value that indicates whether | |
/// `destination` is currently presented. | |
/// - destination: A view for the navigation link to present. | |
public init<S>(_ title: S, isActive: Binding<Bool>, @ViewBuilder destination: () -> Destination) where S : StringProtocol | |
/// Creates a navigation link that presents a destination view when a bound | |
/// selection variable matches a value you provide, using a text label | |
/// that the link generates from a localized string key. | |
/// - Parameters: | |
/// - titleKey: A localized string key for creating a text label. | |
/// - tag: The value of `selection` that causes the link to present | |
/// `destination`. | |
/// - selection: A bound variable that causes the link to present | |
/// `destination` when `selection` becomes equal to `tag`. | |
/// - destination: A view for the navigation link to present. | |
public init<V>(_ titleKey: LocalizedStringKey, tag: V, selection: Binding<V?>, @ViewBuilder destination: () -> Destination) where V : Hashable | |
/// Creates a navigation link that presents a destination view when a bound | |
/// selection variable matches a value you provide, using a text label | |
/// that the link generates from a title string. | |
/// - Parameters: | |
/// - title: A string for creating a text label. | |
/// - tag: The value of `selection` that causes the link to present | |
/// `destination`. | |
/// - selection: A bound variable that causes the link to present | |
/// `destination` when `selection` becomes equal to `tag`. | |
/// - destination: A view for the navigation link to present. | |
public init<S, V>(_ title: S, tag: V, selection: Binding<V?>, @ViewBuilder destination: () -> Destination) where S : StringProtocol, V : Hashable | |
/// Creates a navigation link that presents a destination view, with a text | |
/// label that the link generates from a localized string key. | |
/// - Parameters: | |
/// - titleKey: A localized string key for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
public init(_ titleKey: LocalizedStringKey, destination: Destination) | |
/// Creates a navigation link that presents a destination view, with a text | |
/// label that the link generates from a title string. | |
/// - Parameters: | |
/// - title: A string for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Pass a closure as the destination") | |
public init<S>(_ title: S, destination: Destination) where S : StringProtocol | |
/// Creates a navigation link that presents a destination view when active, with a | |
/// text label that the link generates from a localized string key. | |
/// - Parameters: | |
/// - titleKey: A localized string key for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
/// - isActive: A binding to a Boolean value that indicates whether | |
/// `destination` is currently presented. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
public init(_ titleKey: LocalizedStringKey, destination: Destination, isActive: Binding<Bool>) | |
/// Creates a navigation link that presents a destination view when active, with a | |
/// text label that the link generates from a title string. | |
/// - Parameters: | |
/// - title: A string for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
/// - isActive: A binding to a Boolean value that indicates whether | |
/// `destination` is currently presented. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "NavigationLink(_:isActive:destination:)") | |
public init<S>(_ title: S, destination: Destination, isActive: Binding<Bool>) where S : StringProtocol | |
/// Creates a navigation link that presents a destination view when a bound | |
/// selection variable matches a value you provide, using a text label | |
/// that the link generates from a localized string key. | |
/// - Parameters: | |
/// - titleKey: A localized string key for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
/// - tag: The value of `selection` that causes the link to present | |
/// `destination`. | |
/// - selection: A bound variable that causes the link to present | |
/// `destination` when `selection` becomes equal to `tag`. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
public init<V>(_ titleKey: LocalizedStringKey, destination: Destination, tag: V, selection: Binding<V?>) where V : Hashable | |
/// Creates a navigation link that presents a destination view when a bound | |
/// selection variable matches a value you provide, using a text label | |
/// that the link generates from a title string. | |
/// - Parameters: | |
/// - title: A string for creating a text label. | |
/// - destination: A view for the navigation link to present. | |
/// - tag: The value of `selection` that causes the link to present | |
/// `destination`. | |
/// - selection: A bound variable that causes the link to present | |
/// `destination` when `selection` becomes equal to `tag`. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, renamed: "NavigationLink(_:tag:selection:destination:)") | |
public init<S, V>(_ title: S, destination: Destination, tag: V, selection: Binding<V?>) where S : StringProtocol, V : Hashable | |
} | |
@available(iOS 13.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension NavigationLink { | |
/// Sets the navigation link to present its destination as the detail | |
/// component of the containing navigation view. | |
/// | |
/// This method sets the behavior when the navigation link is used in a | |
/// multi-column navigation view, such as | |
/// ``DoubleColumnNavigationViewStyle``. If `isDetailLink` is `true`, | |
/// performing the link in the primary column sets the contents of the | |
/// secondary (detail) column to be the link's destination view. If | |
/// `isDetailLink` is `false`, the link navigates to the destination view | |
/// within the primary column. | |
/// | |
/// If you do not set the detail link behavior with this method, the | |
/// behavior defaults to `true`. | |
/// | |
/// - Parameter isDetailLink: A Boolean value that specifies whether this | |
/// link presents its destination as the detail component when used in a | |
/// multi-column navigation view. | |
/// - Returns: A view that applies the specified detail link behavior. | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public func isDetailLink(_ isDetailLink: Bool) -> some View | |
} | |
/// A view for presenting a stack of views that represents a visible path in a | |
/// navigation hierarchy. | |
/// | |
/// Use a `NavigationView` to create a navigation-based app in which the user | |
/// can traverse a collection of views. Users navigate to a destination view | |
/// by selecting a ``NavigationLink`` that you provide. On iPadOS and macOS, the | |
/// destination content appears in the next column. Other platforms push a new | |
/// view onto the stack, and enable removing items from the stack with | |
/// platform-specific controls, like a Back button or a swipe gesture. | |
/// | |
/// ![A diagram showing a multicolumn navigation view on | |
/// macOS, and a stack of views on iOS.](NavigationView-1) | |
/// | |
/// Use the ``init(content:)`` initializer to create a | |
/// navigation view that directly associates navigation links and their | |
/// destination views: | |
/// | |
/// NavigationView { | |
/// List(model.notes) { note in | |
/// NavigationLink(note.title, destination: NoteEditor(id: note.id)) | |
/// } | |
/// Text("Select a Note") | |
/// } | |
/// | |
/// Style a navigation view by modifying it with the | |
/// ``View/navigationViewStyle(_:)`` view modifier. Use other modifiers, like | |
/// ``View/navigationTitle(_:)-avgj``, on views presented by the navigation | |
/// view to customize the navigation interface for the presented view. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
public struct NavigationView<Content> : View where Content : View { | |
/// Creates a destination-based navigation view. | |
/// | |
/// Perform navigation by initializing a link with a destination view. | |
/// For example, consider a `ColorDetail` view that displays a color sample: | |
/// | |
/// struct ColorDetail: View { | |
/// var color: Color | |
/// | |
/// var body: some View { | |
/// color | |
/// .frame(width: 200, height: 200) | |
/// .navigationTitle(color.description.capitalized) | |
/// } | |
/// } | |
/// | |
/// The following ``NavigationView`` presents three links to color detail | |
/// views: | |
/// | |
/// NavigationView { | |
/// List { | |
/// NavigationLink("Purple", destination: ColorDetail(color: .purple)) | |
/// NavigationLink("Pink", destination: ColorDetail(color: .pink)) | |
/// NavigationLink("Orange", destination: ColorDetail(color: .orange)) | |
/// } | |
/// .navigationTitle("Colors") | |
/// | |
/// Text("Select a Color") // A placeholder to show before selection. | |
/// } | |
/// | |
/// When the horizontal size class is ``UserInterfaceSizeClass/regular``, | |
/// like on an iPad in landscape mode, or on a Mac, | |
/// the navigation view presents itself as a multicolumn view, | |
/// using its second and later content views --- a single ``Text`` | |
/// view in the example above --- as a placeholder for the corresponding | |
/// column: | |
/// | |
/// ![A screenshot of a Mac window showing a multicolumn navigation view. | |
/// The left column lists the colors Purple, Pink, and Orange, with | |
/// none selected. The right column presents a placeholder view that says | |
/// Select a Color.](NavigationView-init-content-1) | |
/// | |
/// When the user selects one of the navigation links from the | |
/// list, the linked destination view replaces the placeholder | |
/// text in the detail column: | |
/// | |
/// ![A screenshot of a Mac window showing a multicolumn navigation view. | |
/// The left column lists the colors Purple, Pink, and Orange, with | |
/// Purple selected. The right column presents a detail view that shows a | |
/// purple square.](NavigationView-init-content-2) | |
/// | |
/// When the size class is ``UserInterfaceSizeClass/compact``, like | |
/// on an iPhone in portrait orientation, the navigation view presents | |
/// itself as a single column that the user navigates as a stack. Tapping | |
/// one of the links replaces the list with the detail view, which | |
/// provides a back button to return to the list: | |
/// | |
/// ![Two screenshots of an iPhone in portrait orientation connected by an | |
/// arrow. The first screenshot shows a single column consisting of a list | |
/// of colors with the names Purple, Pink, and Orange. The second | |
/// screenshot has the title Purple, and contains a purple square. | |
/// The arrow connects the Purple item in the list on the left to the | |
/// screenshot on the right.](NavigationView-init-content-3) | |
/// | |
/// - Parameter content: A ``ViewBuilder`` that produces the content that | |
/// the navigation view wraps. Any views after the first act as | |
/// placeholders for corresponding columns in a multicolumn display. | |
public init(@ViewBuilder content: () -> Content) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A specification for the appearance and interaction of a `NavigationView`. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
public protocol NavigationViewStyle { | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension NavigationViewStyle where Self == ColumnNavigationViewStyle { | |
/// A navigation view style represented by a series of views in columns. | |
public static var columns: ColumnNavigationViewStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
extension NavigationViewStyle where Self == DefaultNavigationViewStyle { | |
/// The default navigation view style in the current context of the view | |
/// being styled. | |
public static var automatic: DefaultNavigationViewStyle { get } | |
} | |
@available(iOS 13.0, tvOS 13.0, watchOS 7.0, *) | |
@available(macOS, unavailable) | |
extension NavigationViewStyle where Self == StackNavigationViewStyle { | |
/// A navigation view style represented by a view stack that only shows a | |
/// single top view at a time. | |
public static var stack: StackNavigationViewStyle { get } | |
} | |
/// A property wrapper type that subscribes to an observable object and | |
/// invalidates a view whenever the observable object changes. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@propertyWrapper @frozen public struct ObservedObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject { | |
/// A wrapper of the underlying observable object that can create bindings to | |
/// its properties using dynamic member lookup. | |
@dynamicMemberLookup @frozen public struct Wrapper { | |
/// Returns a binding to the resulting value of a given key path. | |
/// | |
/// - Parameter keyPath : A key path to a specific resulting value. | |
/// | |
/// - Returns: A new binding. | |
public subscript<Subject>(dynamicMember keyPath: ReferenceWritableKeyPath<ObjectType, Subject>) -> Binding<Subject> { get } | |
} | |
/// Creates an observed object with an initial value. | |
/// | |
/// - Parameter initialValue: An initial value. | |
public init(initialValue: ObjectType) | |
/// Creates an observed object with an initial wrapped value. | |
/// | |
/// You don't call this initializer directly. Instead, declare a property | |
/// with the `@ObservedObject` attribute, and provide an initial value. | |
/// | |
/// - Parameter wrappedValue: An initial value. | |
public init(wrappedValue: ObjectType) | |
/// The underlying value referenced by the observed object. | |
/// | |
/// This property provides primary access to the value's data. However, you | |
/// don't access `wrappedValue` directly. Instead, you use the property | |
/// variable created with the `@ObservedObject` attribute. | |
/// | |
/// When a mutable value changes, the new value is immediately available. | |
/// However, a view displaying the value is updated asynchronously and may | |
/// not show the new value immediately. | |
public var wrappedValue: ObjectType | |
/// A projection of the observed object that creates bindings to its | |
/// properties using dynamic member lookup. | |
/// | |
/// Use the projected value to pass a binding value down a view hierarchy. | |
/// To get the `projectedValue`, prefix the property variable with `$`. | |
public var projectedValue: ObservedObject<ObjectType>.Wrapper { get } | |
} | |
/// A shape with a translation offset transform applied to it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct OffsetShape<Content> : Shape where Content : Shape { | |
public var shape: Content | |
public var offset: CGSize | |
@inlinable public init(shape: Content, offset: CGSize) | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in rect: CGRect) -> Path | |
/// An indication of how to style a shape. | |
/// | |
/// SwiftUI looks at a shape's role when deciding how to apply a | |
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a | |
/// default implementation with a value of ``ShapeRole/fill``. If you | |
/// create a composite shape, you can provide an override of this property | |
/// to return another value, if appropriate. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var role: ShapeRole { get } | |
/// The type defining the data to animate. | |
public typealias AnimatableData = AnimatablePair<Content.AnimatableData, CGSize.AnimatableData> | |
/// The data to animate. | |
public var animatableData: OffsetShape<Content>.AnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension OffsetShape : InsettableShape where Content : InsettableShape { | |
/// Returns `self` inset by `amount`. | |
@inlinable public func inset(by amount: CGFloat) -> OffsetShape<Content.InsetShape> | |
/// The type of the inset shape. | |
public typealias InsetShape = OffsetShape<Content.InsetShape> | |
} | |
/// Provides functionality for opening a URL. | |
/// | |
/// The `OpenURLAction` instance in the app's ``Environment`` offers | |
/// a handler that you can use to open a URL in response to some action. | |
/// Use the ``EnvironmentValues/openURL`` environment value to get the handler. | |
/// Then call the action's handler when you need to open a URL. For example, | |
/// you can open a support URL in response to when a user taps a button: | |
/// | |
/// struct OpenUrlActionView: View { | |
/// @Environment(\.openURL) var openURL | |
/// | |
/// var body: some View { | |
/// Button(action: contactSupport) { | |
/// Text("Email Support") | |
/// Image(systemName: "envelope.open") | |
/// } | |
/// } | |
/// | |
/// func contactSupport() { | |
/// guard let url = URL(string: "https://www.example.com") else { | |
/// return | |
/// } | |
/// openURL(url) | |
/// } | |
/// } | |
/// | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct OpenURLAction { | |
/// Opens a URL, following system conventions. | |
/// | |
/// Use this method to attempt to open a URL. This function handles the | |
/// calling of the platform specific URL handler contained in the | |
/// `openURL` property stored the app's ``Environment``, and is used when | |
/// you call the function ``openURL(:_)``. | |
/// | |
/// - Parameters: | |
/// - url: The URL to open. | |
public func callAsFunction(_ url: URL) | |
/// Asynchronously opens a URL, following system conventions. | |
/// | |
/// Use this method when attempting to asynchronously open a URL; the | |
/// result indicates whether the system was able open the URL. | |
/// The completion runs after the system decides that it can open the URL, | |
/// but the full opening of the URL may not yet be complete when calling the | |
/// completion handler. | |
/// | |
/// - Parameters: | |
/// - url: The URL to open. | |
/// - completion: A closure the method calls after determining if | |
/// it is possible to open the URL, although possibly before fully | |
/// opening the URL. The closure takes a Boolean that indicates whether | |
/// the URL can be opened. | |
@available(watchOS, unavailable) | |
public func callAsFunction(_ url: URL, completion: @escaping (_ accepted: Bool) -> Void) | |
} | |
/// A structure that computes views and disclosure groups on demand from an | |
/// underlying collection of tree-structured, identified data. | |
/// | |
/// Use an outline group when you need a view that can represent a hierarchy | |
/// of data by using disclosure views. This allows the user to navigate the | |
/// tree structure by using the disclosure views to expand and collapse | |
/// branches. | |
/// | |
/// In the following example, a tree structure of `FileItem` data offers a | |
/// simplified view of a file system. Passing the root of this tree and the | |
/// key path of its children allows you to quickly create a visual | |
/// representation of the file system. | |
/// | |
/// struct FileItem: Hashable, Identifiable, CustomStringConvertible { | |
/// var id: Self { self } | |
/// var name: String | |
/// var children: [FileItem]? = nil | |
/// var description: String { | |
/// switch children { | |
/// case nil: | |
/// return "📄 \(name)" | |
/// case .some(let children): | |
/// return children.isEmpty ? "📂 \(name)" : "📁 \(name)" | |
/// } | |
/// } | |
/// } | |
/// | |
/// let data = | |
/// FileItem(name: "users", children: | |
/// [FileItem(name: "user1234", children: | |
/// [FileItem(name: "Photos", children: | |
/// [FileItem(name: "photo001.jpg"), | |
/// FileItem(name: "photo002.jpg")]), | |
/// FileItem(name: "Movies", children: | |
/// [FileItem(name: "movie001.mp4")]), | |
/// FileItem(name: "Documents", children: []) | |
/// ]), | |
/// FileItem(name: "newuser", children: | |
/// [FileItem(name: "Documents", children: []) | |
/// ]) | |
/// ]) | |
/// | |
/// OutlineGroup(data, children: \.children) { item in | |
/// Text("\(item.description)") | |
/// } | |
/// | |
/// ### Type Parameters | |
/// | |
/// Five generic type constraints define a specific `OutlineGroup` instance: | |
/// | |
/// - `Data`: The type of a collection containing the children of an element in | |
/// the tree-shaped data. | |
/// - `ID`: The type of the identifier for an element. | |
/// - `Parent`: The type of the visual representation of an element whose | |
/// children property is non-`nil` | |
/// - `Leaf`: The type of the visual representation of an element whose | |
/// children property is `nil`. | |
/// - `Subgroup`: A type of a view that groups a parent view and a view | |
/// representing its children, typically with some mechanism for showing and | |
/// hiding the children | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct OutlineGroup<Data, ID, Parent, Leaf, Subgroup> where Data : RandomAccessCollection, ID : Hashable { | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension OutlineGroup where ID == Data.Element.ID, Parent : View, Parent == Leaf, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren>, Data.Element : Identifiable { | |
/// Creates an outline group from a root data element and a key path to | |
/// its children. | |
/// | |
/// This initializer creates an instance that uniquely identifies views | |
/// across updates based on the identity of the underlying data element. | |
/// | |
/// All generated disclosure groups begin in the collapsed state. | |
/// | |
/// Make sure that the identifier of a data element only changes if you | |
/// mean to replace that element with a new element, one with a new | |
/// identity. If the ID of an element changes, then the content view | |
/// generated from that element will lose any current state and animations. | |
/// | |
/// - Parameters: | |
/// - root: The root of a collection of tree-structured, identified | |
/// data. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes an element | |
/// capable of having children that's currently childless, such as an | |
/// empty directory in a file system. On the other hand, if the property | |
/// at the key path is `nil`, then the outline group treats `data` as a | |
/// leaf in the tree, like a regular file in a file system. | |
/// - content: A view builder that produces a content view based on an | |
/// element in `data`. | |
public init<DataElement>(_ root: DataElement, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement : Identifiable, DataElement == Data.Element | |
/// Creates an outline group from a collection of root data elements and | |
/// a key path to its children. | |
/// | |
/// This initializer creates an instance that uniquely identifies views | |
/// across updates based on the identity of the underlying data element. | |
/// | |
/// All generated disclosure groups begin in the collapsed state. | |
/// | |
/// Make sure that the identifier of a data element only changes if you | |
/// mean to replace that element with a new element, one with a new | |
/// identity. If the ID of an element changes, then the content view | |
/// generated from that element will lose any current state and animations. | |
/// | |
/// - Parameters: | |
/// - data: A collection of tree-structured, identified data. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes an element | |
/// capable of having children that's currently childless, such as an | |
/// empty directory in a file system. On the other hand, if the property | |
/// at the key path is `nil`, then the outline group treats `data` as a | |
/// leaf in the tree, like a regular file in a file system. | |
/// - content: A view builder that produces a content view based on an | |
/// element in `data`. | |
public init<DataElement>(_ data: Data, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement : Identifiable, DataElement == Data.Element | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension OutlineGroup where Parent : View, Parent == Leaf, Subgroup == DisclosureGroup<Parent, OutlineSubgroupChildren> { | |
/// Creates an outline group from a root data element, the key path to its | |
/// identifier, and a key path to its children. | |
/// | |
/// This initializer creates an instance that uniquely identifies views | |
/// across updates based on the identity of the underlying data element. | |
/// | |
/// All generated disclosure groups begin in the collapsed state. | |
/// | |
/// Make sure that the identifier of a data element only changes if you | |
/// mean to replace that element with a new element, one with a new | |
/// identity. If the ID of an element changes, then the content view | |
/// generated from that element will lose any current state and animations. | |
/// | |
/// - Parameters: | |
/// - root: The root of a collection of tree-structured, identified | |
/// data. | |
/// - id: The key path to a data element's identifier. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes an element | |
/// capable of having children that's currently childless, such as an | |
/// empty directory in a file system. On the other hand, if the property | |
/// at the key path is `nil`, then the outline group treats `data` as a | |
/// leaf in the tree, like a regular file in a file system. | |
/// - content: A view builder that produces a content view based on an | |
/// element in `data`. | |
public init<DataElement>(_ root: DataElement, id: KeyPath<DataElement, ID>, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where DataElement == Data.Element | |
/// Creates an outline group from a collection of root data elements, the | |
/// key path to a data element's identifier, and a key path to its children. | |
/// | |
/// This initializer creates an instance that uniquely identifies views | |
/// across updates based on the identity of the underlying data element. | |
/// | |
/// All generated disclosure groups begin in the collapsed state. | |
/// | |
/// Make sure that the identifier of a data element only changes if you | |
/// mean to replace that element with a new element, one with a new | |
/// identity. If the ID of an element changes, then the content view | |
/// generated from that element will lose any current state and animations. | |
/// | |
/// - Parameters: | |
/// - data: A collection of tree-structured, identified data. | |
/// - id: The key path to a data element's identifier. | |
/// - children: A key path to a property whose non-`nil` value gives the | |
/// children of `data`. A non-`nil` but empty value denotes an element | |
/// capable of having children that's currently childless, such as an | |
/// empty directory in a file system. On the other hand, if the property | |
/// at the key path is `nil`, then the outline group treats `data` as a | |
/// leaf in the tree, like a regular file in a file system. | |
/// - content: A view builder that produces a content view based on an | |
/// element in `data`. | |
public init<DataElement>(_ data: Data, id: KeyPath<DataElement, ID>, children: KeyPath<DataElement, Data?>, @ViewBuilder content: @escaping (DataElement) -> Leaf) where DataElement == Data.Element | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension OutlineGroup : View where Parent : View, Leaf : View, Subgroup : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
/// A type-erased view representing the children in an outline subgroup. | |
/// | |
/// ``OutlineGroup`` uses this type as a generic constraint for the `Content` | |
/// of the ``DisclosureGroup`` instances it creates. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct OutlineSubgroupChildren : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// An index view style that places a page index view over its content. | |
/// | |
/// Do not use this type directly. Instead, use ``IndexViewStyle/page``. | |
@available(iOS 14.0, tvOS 14.0, watchOS 8.0, *) | |
@available(macOS, unavailable) | |
public struct PageIndexViewStyle : IndexViewStyle { | |
/// The background style for the page index view. | |
public struct BackgroundDisplayMode { | |
/// Background will use the default for the platform. | |
public static let automatic: PageIndexViewStyle.BackgroundDisplayMode | |
/// Background is only shown while the index view is interacted with. | |
@available(watchOS, unavailable) | |
public static let interactive: PageIndexViewStyle.BackgroundDisplayMode | |
/// Background is always displayed behind the page index view. | |
@available(watchOS, unavailable) | |
public static let always: PageIndexViewStyle.BackgroundDisplayMode | |
/// Background is never displayed behind the page index view. | |
public static let never: PageIndexViewStyle.BackgroundDisplayMode | |
} | |
/// Creates a page index view style. | |
/// | |
/// - Parameter backgroundDisplayMode: The display mode of the background of any | |
/// page index views receiving this style | |
public init(backgroundDisplayMode: PageIndexViewStyle.BackgroundDisplayMode = .automatic) | |
} | |
/// A `TabViewStyle` that implements a paged scrolling `TabView`. | |
/// | |
/// Do not use this type directly. Instead, use ``TabViewStyle/page``. | |
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *) | |
@available(macOS, unavailable) | |
public struct PageTabViewStyle : TabViewStyle { | |
/// A style for displaying the page index view | |
public struct IndexDisplayMode { | |
/// Displays an index view when there are more than one page | |
public static let automatic: PageTabViewStyle.IndexDisplayMode | |
/// Always display an index view regardless of page count | |
@available(watchOS 8.0, *) | |
public static let always: PageTabViewStyle.IndexDisplayMode | |
/// Never display an index view | |
@available(watchOS 8.0, *) | |
public static let never: PageTabViewStyle.IndexDisplayMode | |
} | |
/// Creates a new `PageTabViewStyle` with an index display mode | |
public init(indexDisplayMode: PageTabViewStyle.IndexDisplayMode = .automatic) | |
} | |
/// The outline of a 2D shape. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Path : Equatable, LosslessStringConvertible { | |
/// Creates an empty path. | |
public init() | |
/// Creates a path from an immutable shape path. | |
public init(_ path: CGPath) | |
/// Creates a path from a copy of a mutable shape path. | |
public init(_ path: CGMutablePath) | |
/// Creates a path as the given rectangle. | |
public init(_ rect: CGRect) | |
/// Creates a path as the given rounded rectangle. | |
public init(roundedRect rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .circular) | |
/// Creates a path as the given rounded rectangle. | |
public init(roundedRect rect: CGRect, cornerRadius: CGFloat, style: RoundedCornerStyle = .circular) | |
/// Creates a path as an ellipse inscribed within the given rectangle. | |
public init(ellipseIn rect: CGRect) | |
/// Creates an empty path, and then executes the closure to add the initial | |
/// elements. | |
public init(_ callback: (inout Path) -> ()) | |
/// Initializes from the result of a previous call to | |
/// `Path.stringRepresentation`. Fails if the `string` does not | |
/// describe a valid path. | |
public init?(_ string: String) | |
/// A description of the path that may be used to recreate the path | |
/// via `init?(_:)`. | |
public var description: String { get } | |
/// An immutable path representing the elements in the path. | |
public var cgPath: CGPath { get } | |
/// A Boolean value indicating whether the path contains zero elements. | |
public var isEmpty: Bool { get } | |
/// A rectangle containing all path segments. | |
public var boundingRect: CGRect { get } | |
/// Returns true if the path contains a specified point. | |
/// | |
/// If `eoFill` is true, this method uses the even-odd rule to define which | |
/// points are inside the path. Otherwise, it uses the non-zero rule. | |
public func contains(_ p: CGPoint, eoFill: Bool = false) -> Bool | |
/// An element of a path. | |
@frozen public enum Element : Equatable { | |
/// A path element that terminates the current subpath (without closing | |
/// it) and defines a new current point. | |
case move(to: CGPoint) | |
/// A line from the previous current point to the given point, which | |
/// becomes the new current point. | |
case line(to: CGPoint) | |
/// A quadratic Bézier curve from the previous current point to the | |
/// given end-point, using the single control point to define the curve. | |
/// | |
/// The end-point of the curve becomes the new current point. | |
case quadCurve(to: CGPoint, control: CGPoint) | |
/// A cubic Bézier curve from the previous current point to the given | |
/// end-point, using the two control points to define the curve. | |
/// | |
/// The end-point of the curve becomes the new current point. | |
case curve(to: CGPoint, control1: CGPoint, control2: CGPoint) | |
/// A line from the start point of the current subpath (if any) to the | |
/// current point, which terminates the subpath. | |
/// | |
/// After closing the subpath, the current point becomes undefined. | |
case closeSubpath | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Path.Element, b: Path.Element) -> Bool | |
} | |
/// Calls `body` with each element in the path. | |
public func forEach(_ body: (Path.Element) -> Void) | |
/// Returns a stroked copy of the path using `style` to define how the | |
/// stroked outline is created. | |
public func strokedPath(_ style: StrokeStyle) -> Path | |
/// Returns a partial copy of the path. | |
/// | |
/// The returned path contains the region between `from` and `to`, both of | |
/// which must be fractions between zero and one defining points | |
/// linearly-interpolated along the path. | |
public func trimmedPath(from: CGFloat, to: CGFloat) -> Path | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Path, b: Path) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Path : Shape { | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in _: CGRect) -> Path | |
/// The type defining the data to animate. | |
public typealias AnimatableData = EmptyAnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Path { | |
/// Begins a new subpath at the specified point. | |
public mutating func move(to p: CGPoint) | |
/// Appends a straight line segment from the current point to the specified | |
/// point. | |
public mutating func addLine(to p: CGPoint) | |
/// Adds a quadratic Bézier curve to the path, with the specified end point | |
/// and control point. | |
public mutating func addQuadCurve(to p: CGPoint, control cp: CGPoint) | |
/// Adds a cubic Bézier curve to the path, with the specified end point and | |
/// control points. | |
public mutating func addCurve(to p: CGPoint, control1 cp1: CGPoint, control2 cp2: CGPoint) | |
/// Closes and completes the current subpath. | |
public mutating func closeSubpath() | |
/// Adds a rectangular subpath to the path. | |
public mutating func addRect(_ rect: CGRect, transform: CGAffineTransform = .identity) | |
/// Adds a rounded rectangle to the path. | |
public mutating func addRoundedRect(in rect: CGRect, cornerSize: CGSize, style: RoundedCornerStyle = .circular, transform: CGAffineTransform = .identity) | |
/// Adds an ellipse to the path. | |
public mutating func addEllipse(in rect: CGRect, transform: CGAffineTransform = .identity) | |
/// Adds a sequence of rectangular subpaths to the path. | |
public mutating func addRects(_ rects: [CGRect], transform: CGAffineTransform = .identity) | |
/// Adds a sequence of connected straight-line segments to the path. | |
public mutating func addLines(_ lines: [CGPoint]) | |
/// Adds an arc of a circle to the path, specified with a radius and a | |
/// difference in angle. | |
public mutating func addRelativeArc(center: CGPoint, radius: CGFloat, startAngle: Angle, delta: Angle, transform: CGAffineTransform = .identity) | |
/// Adds an arc of a circle to the path, specified with a radius and angles. | |
public mutating func addArc(center: CGPoint, radius: CGFloat, startAngle: Angle, endAngle: Angle, clockwise: Bool, transform: CGAffineTransform = .identity) | |
/// Adds an arc of a circle to the path, specified with a radius and two | |
/// tangent lines. | |
public mutating func addArc(tangent1End p1: CGPoint, tangent2End p2: CGPoint, radius: CGFloat, transform: CGAffineTransform = .identity) | |
/// Appends a copy of the given path to this path. | |
public mutating func addPath(_ path: Path, transform: CGAffineTransform = .identity) | |
/// Returns the last point in the path, or nil if the path contains | |
/// no points. | |
public var currentPoint: CGPoint? { get } | |
/// Returns a path constructed by applying the transform to all points of | |
/// the path. | |
public func applying(_ transform: CGAffineTransform) -> Path | |
/// Returns a path constructed by translating `self` by `(dx, dy)`. | |
public func offsetBy(dx: CGFloat, dy: CGFloat) -> Path | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Path.Element : Sendable { | |
} | |
/// A schedule for updating a timeline view at regular intervals. | |
/// | |
/// Do not use this type directly. Instead, use | |
/// ``TimelineSchedule/periodic(from:by:)``. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct PeriodicTimelineSchedule : TimelineSchedule { | |
/// The sequence of dates in periodic schedule. | |
/// | |
/// The ``PeriodicTimelineSchedule/entries(from:mode:)`` method returns | |
/// a value of this type, which is a | |
/// <doc://com.apple.documentation/documentation/Swift/Sequence> | |
/// of periodic dates in ascending order. A ``TimelineView`` that you | |
/// create updates its content at the moments in time corresponding to the | |
/// dates included in the sequence. | |
public struct Entries : Sequence, IteratorProtocol { | |
/// Advances to the next element and returns it, or `nil` if no next element | |
/// exists. | |
/// | |
/// Repeatedly calling this method returns, in order, all the elements of the | |
/// underlying sequence. As soon as the sequence has run out of elements, all | |
/// subsequent calls return `nil`. | |
/// | |
/// You must not call this method if any other copy of this iterator has been | |
/// advanced with a call to its `next()` method. | |
/// | |
/// The following example shows how an iterator can be used explicitly to | |
/// emulate a `for`-`in` loop. First, retrieve a sequence's iterator, and | |
/// then call the iterator's `next()` method until it returns `nil`. | |
/// | |
/// let numbers = [2, 3, 5, 7] | |
/// var numbersIterator = numbers.makeIterator() | |
/// | |
/// while let num = numbersIterator.next() { | |
/// print(num) | |
/// } | |
/// // Prints "2" | |
/// // Prints "3" | |
/// // Prints "5" | |
/// // Prints "7" | |
/// | |
/// - Returns: The next element in the underlying sequence, if a next element | |
/// exists; otherwise, `nil`. | |
public mutating func next() -> Date? | |
/// A type representing the sequence's elements. | |
public typealias Element = Date | |
/// A type that provides the sequence's iteration interface and | |
/// encapsulates its iteration state. | |
public typealias Iterator = PeriodicTimelineSchedule.Entries | |
} | |
/// Creates a periodic update schedule. | |
/// | |
/// Use the ``PeriodicTimelineSchedule/entries(from:mode:)`` method | |
/// to get the sequence of dates. | |
/// | |
/// - Parameters: | |
/// - startDate: The date on which to start the sequence. | |
/// - interval: The time interval between successive sequence entries. | |
@available(iOS, introduced: 15.0, deprecated: 15.0, message: "Use `.periodic(from:by:)` instead.") | |
@available(macOS, introduced: 12.0, deprecated: 12.0, message: "Use `.periodic(from:by:)` instead.") | |
@available(tvOS, introduced: 15.0, deprecated: 15.0, message: "Use `.periodic(from:by:)` instead.") | |
@available(watchOS, introduced: 8.0, deprecated: 8.0, message: "Use `.periodic(from:by:)` instead.") | |
public init(from startDate: Date, by interval: TimeInterval) | |
/// Provides a sequence of periodic dates starting from around a given date. | |
/// | |
/// A ``TimelineView`` that you create with a schedule calls this method | |
/// to ask the schedule when to update its content. The method returns | |
/// a sequence of equally spaced dates in increasing order that represent | |
/// points in time when the timeline view should update. | |
/// | |
/// The schedule defines its periodicity and phase aligment based on the | |
/// parameters you pass to its ``init(from:by:)`` initializer. | |
/// For example, for a `startDate` and `interval` of `10:09:30` and | |
/// `60` seconds, the schedule prepares to issue dates half past each | |
/// minute. The `startDate` that you pass to the `entries(from:mode:)` | |
/// method then dictates the first date of the sequence as the beginning of | |
/// the interval that the start date overlaps. Continuing the example above, | |
/// a start date of `10:34:45` causes the first sequence entry to be | |
/// `10:34:30`, because that's the start of the interval in which the | |
/// start date appears. | |
public func entries(from startDate: Date, mode: TimelineScheduleMode) -> PeriodicTimelineSchedule.Entries | |
} | |
/// A control for selecting from a set of mutually exclusive values. | |
/// | |
/// You create a picker by providing a selection binding, a label, and the | |
/// content for the picker to display. Set the `selection` parameter to a bound | |
/// property that provides the value to display as the current selection. Set | |
/// the label to a view that visually describes the purpose of selecting content | |
/// in the picker, and then provide the content for the picker to display. | |
/// | |
/// For example, consider the following enumeration of ice cream flavors: | |
/// | |
/// enum Flavor: String, CaseIterable, Identifiable { | |
/// case chocolate | |
/// case vanilla | |
/// case strawberry | |
/// | |
/// var id: String { self.rawValue } | |
/// } | |
/// | |
/// You can create a picker to select among these values by providing ``Text`` | |
/// views in the picker initializer's content. You can optionally provide a | |
/// string as the first parameter; if you do, the picker creates a ``Text`` | |
/// label using this string: | |
/// | |
/// @State private var selectedFlavor = Flavor.chocolate | |
/// | |
/// Picker("Flavor", selection: $selectedFlavor) { | |
/// Text("Chocolate").tag(Flavor.chocolate) | |
/// Text("Vanilla").tag(Flavor.vanilla) | |
/// Text("Strawberry").tag(Flavor.strawberry) | |
/// } | |
/// Text("Selected flavor: \(selectedFlavor.rawValue)") | |
/// | |
/// You append a tag to each text view so that the type of each selection | |
/// matches the type of the bound state variable. | |
/// | |
/// ### Iterating Over a Picker’s Options | |
/// | |
/// To provide selection values for the `Picker` without explicitly listing | |
/// each option, you can create the picker with a ``ForEach`` construct, like | |
/// this: | |
/// | |
/// Picker("Flavor", selection: $selectedFlavor) { | |
/// ForEach(Flavor.allCases) { flavor in | |
/// Text(flavor.rawValue.capitalized) | |
/// } | |
/// } | |
/// | |
/// In this case, ``ForEach`` automatically assigns a tag to the selection | |
/// views, using each option's `id`, which it can do because `Flavor` conforms | |
/// to the <doc://com.apple.documentation/documentation/Swift/Identifiable> | |
/// protocol. | |
/// | |
/// On the other hand, if the selection type doesn't match the input to the | |
/// ``ForEach``, you need to provide an explicit tag. The following example | |
/// shows a picker that's bound to a `Topping` type, even though the options | |
/// are all `Flavor` instances. Each option uses ``View/tag(_:)`` to associate | |
/// a topping with the flavor it displays. | |
/// | |
/// enum Topping: String, CaseIterable, Identifiable { | |
/// case nuts | |
/// case cookies | |
/// case blueberries | |
/// | |
/// var id: String { self.rawValue } | |
/// } | |
/// extension Flavor { | |
/// var suggestedTopping: Topping { | |
/// switch self { | |
/// case .chocolate: return .nuts | |
/// case .vanilla: return .cookies | |
/// case .strawberry: return .blueberries | |
/// } | |
/// } | |
/// } | |
/// @State var suggestedTopping: Topping = .cookies | |
/// | |
/// Picker("Suggest a topping for:", selection: $suggestedTopping) { | |
/// ForEach(Flavor.allCases) { flavor in | |
/// Text(flavor.rawValue.capitalized) | |
/// .tag(flavor.suggestedTopping) | |
/// } | |
/// } | |
/// Text("suggestedTopping: \(suggestedTopping.rawValue)") | |
/// | |
/// ### Styling Pickers | |
/// | |
/// You can customize the appearance and interaction of pickers by creating | |
/// styles that conform to the ``PickerStyle`` protocol. You create your own style | |
/// or use one of the styles provided by SwiftUI, like ``PickerStyle/segmented`` | |
/// or ``PickerStyle/menu``. | |
/// | |
/// To set a specific style for all picker instances within a view, use the | |
/// ``View/pickerStyle(_:)`` modifier. The following example adds a second binding | |
/// type, `Topping`, and applies the ``PickerStyle/segmented`` style to two pickers: | |
/// | |
/// @State private var selectedFlavor = Flavor.chocolate | |
/// @State private var selectedTopping = Topping.nuts | |
/// | |
/// VStack { | |
/// Picker("Flavor", selection: $selectedFlavor) { | |
/// ForEach(Flavor.allCases) { flavor in | |
/// Text(flavor.rawValue.capitalized) | |
/// } | |
/// } | |
/// Picker("Topping", selection: $selectedTopping) { | |
/// ForEach(Topping.allCases) { flavor in | |
/// Text(flavor.rawValue.capitalized) | |
/// } | |
/// } | |
/// | |
/// Text("Selected flavor: \(selectedFlavor.rawValue)") | |
/// Text("Selected topping: \(selectedTopping.rawValue)") | |
/// } | |
/// .pickerStyle(.segmented) | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct Picker<Label, SelectionValue, Content> : View where Label : View, SelectionValue : Hashable, Content : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Picker { | |
/// Creates a picker that displays a custom label. | |
/// | |
/// - Parameters: | |
/// - selection: A binding to a property that determines the | |
/// currently-selected option. | |
/// - content: A view that contains the set of options. | |
/// - label: A view that describes the purpose of selecting an option. | |
public init(selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Picker where Label == Text { | |
/// Creates a picker that generates its label from a localized string key. | |
/// | |
/// - Parameters: | |
/// - titleKey: A localized string key that describes the purpose of | |
/// selecting an option. | |
/// - selection: A binding to a property that determines the | |
/// currently-selected option. | |
/// - content: A view that contains the set of options. | |
/// | |
/// This initializer creates a ``Text`` view on your behalf, and treats the | |
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See | |
/// ``Text`` for more information about localizing strings. | |
/// | |
/// To initialize a picker with a string variable, use | |
/// ``init(_:selection:content:)-5njtq`` instead. | |
public init(_ titleKey: LocalizedStringKey, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content) | |
/// Creates a picker that generates its label from a string. | |
/// | |
/// - Parameters: | |
/// - title: A string that describes the purpose of selecting an option. | |
/// - selection: A binding to a property that determines the | |
/// currently-selected option. | |
/// - content: A view that contains the set of options. | |
/// | |
/// This initializer creates a ``Text`` view on your behalf, and treats the | |
/// title similar to ``Text/init(_:)-9d1g4``. See ``Text`` for more | |
/// information about localizing strings. | |
/// | |
/// To initialize a picker with a localized string key, use | |
/// ``init(_:selection:content:)-6lwfn`` instead. | |
public init<S>(_ title: S, selection: Binding<SelectionValue>, @ViewBuilder content: () -> Content) where S : StringProtocol | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Picker { | |
/// Creates a picker that displays a custom label. | |
/// | |
/// - Parameters: | |
/// - selection: A binding to a property that determines the | |
/// currently-selected option. | |
/// - label: A view that describes the purpose of selecting an option. | |
/// - content: A view that contains the set of options. | |
@available(iOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)") | |
@available(tvOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Picker(selection:content:label:)") | |
public init(selection: Binding<SelectionValue>, label: Label, @ViewBuilder content: () -> Content) | |
} | |
/// A type that specifies the appearance and interaction of all pickers within | |
/// a view hierarchy. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol PickerStyle { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) | |
@available(watchOS, unavailable) | |
extension PickerStyle where Self == SegmentedPickerStyle { | |
/// A picker style that presents the options as a group of radio buttons. | |
/// | |
/// Use this style when there are two to five options. Consider using | |
/// ``PickerStyle/menu`` when there are more than five options. | |
/// | |
/// For each option's label, use sentence-style capitalization without | |
/// ending punctuation, like a period or colon. | |
/// | |
/// To apply this style to a picker, or to a view that contains pickers, use | |
/// the ``View/pickerStyle(_:)`` modifier. | |
public static var segmented: SegmentedPickerStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension PickerStyle where Self == InlinePickerStyle { | |
/// A `PickerStyle` where each option is displayed inline with other views | |
/// in the current container. | |
public static var inline: InlinePickerStyle { get } | |
} | |
@available(iOS 13.0, watchOS 6.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
extension PickerStyle where Self == WheelPickerStyle { | |
/// A picker style that presents the options in a scrollable wheel that | |
/// shows the selected option and a few neighboring options. | |
/// | |
/// Because most options aren't visible, organize them in a predictable | |
/// order, such as alphabetically. | |
/// | |
/// To apply this style to a picker, or to a view that contains pickers, use | |
/// the ``View/pickerStyle(_:)`` modifier. | |
public static var wheel: WheelPickerStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PickerStyle where Self == DefaultPickerStyle { | |
/// The default picker style, based on the picker's context. | |
/// | |
/// How a picker using the default picker style appears largely depends on | |
/// the platform and the view type in which it appears. For example, in a | |
/// standard view, the default picker styles by platform are: | |
/// | |
/// * On iOS and watchOS the default is a wheel. | |
/// * On macOS, the default is a pop-up button. | |
/// * On tvOS, the default is a segmented control. | |
/// | |
/// The default picker style may also take into account other factors — like | |
/// whether the picker appears in a container view — when setting the | |
/// appearance of a picker. | |
/// | |
/// You can override a picker’s style. To apply the default style to a | |
/// picker, or to a view that contains pickers, use the | |
/// ``View/pickerStyle(_:)`` modifier. | |
public static var automatic: DefaultPickerStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension PickerStyle where Self == MenuPickerStyle { | |
/// A picker style that presents the options as a menu when the user presses a | |
/// button, or as a submenu when nested within a larger menu. | |
/// | |
/// Use this style when there are more than five options. Consider using | |
/// ``PickerStyle/inline`` when there are fewer than five options. | |
/// | |
/// The button itself indicates the selected option. You can include additional | |
/// controls in the set of options, such as a button to customize the list of | |
/// options. | |
/// | |
/// To apply this style to a picker, or to a view that contains pickers, use the | |
/// ``View/pickerStyle(_:)`` modifier. | |
public static var menu: MenuPickerStyle { get } | |
} | |
/// A set of view types that may be pinned to the bounds of a scroll view. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct PinnedScrollableViews : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt32 | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
public init(rawValue: UInt32) | |
/// The header view of each `Section` will be pinned. | |
public static let sectionHeaders: PinnedScrollableViews | |
/// The footer view of each `Section` will be pinned. | |
public static let sectionFooters: PinnedScrollableViews | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = PinnedScrollableViews | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = PinnedScrollableViews | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt32 | |
} | |
/// A button style that doesn't style or decorate its content while idle, but | |
/// may apply a visual effect to indicate the pressed, focused, or enabled state | |
/// of the button. | |
/// | |
/// Do not use this type directly. Instead, use ``PrimitiveButtonStyle/plain``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct PlainButtonStyle : PrimitiveButtonStyle { | |
/// Creates a plain button style. | |
public init() | |
/// Creates a view that represents the body of a button. | |
/// | |
/// The system calls this method for each ``Button`` instance in a view | |
/// hierarchy where this style is the current button style. | |
/// | |
/// - Parameter configuration : The properties of the button. | |
public func makeBody(configuration: PlainButtonStyle.Configuration) -> some View | |
/// A view that represents the body of a button. | |
public typealias Body = some View | |
} | |
/// The list style that describes the behavior and appearance of a plain list. | |
/// | |
/// Do not use this type directly. Instead, use ``ListStyle/plain``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct PlainListStyle : ListStyle { | |
/// Creates a plain list style. | |
public init() | |
} | |
/// A text field style with no decoration. | |
/// | |
/// Do not use this type directly. Instead, use ``TextFieldStyle/plain``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct PlainTextFieldStyle : TextFieldStyle { | |
public init() | |
} | |
/// An attachment anchor for a popover. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public enum PopoverAttachmentAnchor { | |
/// The anchor point for the popover relative to the source's frame. | |
case rect(Anchor<CGRect>.Source) | |
/// The anchor point for the popover expressed as a unit point that | |
/// describes possible alignments relative to a SwiftUI view. | |
case point(UnitPoint) | |
} | |
/// A named value produced by a view. | |
/// | |
/// A view with multiple children automatically combines its values for a given | |
/// preference into a single value visible to its ancestors. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol PreferenceKey { | |
/// The type of value produced by this preference. | |
associatedtype Value | |
/// The default value of the preference. | |
/// | |
/// Views that have no explicit value for the key produce this default | |
/// value. Combining child views may remove an implicit value produced by | |
/// using the default. This means that `reduce(value: &x, nextValue: | |
/// {defaultValue})` shouldn't change the meaning of `x`. | |
static var defaultValue: Self.Value { get } | |
/// Combines a sequence of values by modifying the previously-accumulated | |
/// value with the result of a closure that provides the next value. | |
/// | |
/// This method receives its values in view-tree order. Conceptually, this | |
/// combines the preference value from one tree with that of its next | |
/// sibling. | |
/// | |
/// - Parameters: | |
/// - value: The value accumulated through previous calls to this method. | |
/// The implementation should modify this value. | |
/// - nextValue: A closure that returns the next value in the sequence. | |
static func reduce(value: inout Self.Value, nextValue: () -> Self.Value) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PreferenceKey where Self.Value : ExpressibleByNilLiteral { | |
/// Let nil-expressible values default-initialize to nil. | |
public static var defaultValue: Self.Value { get } | |
} | |
/// A key for specifying the preferred color scheme. | |
@available(iOS 13.0, macOS 11.0, tvOS 13.0, watchOS 6.0, *) | |
public struct PreferredColorSchemeKey : PreferenceKey { | |
/// The type of value produced by this preference. | |
public typealias Value = ColorScheme? | |
/// Combines a sequence of values by modifying the previously-accumulated | |
/// value with the result of a closure that provides the next value. | |
/// | |
/// This method receives its values in view-tree order. Conceptually, this | |
/// combines the preference value from one tree with that of its next | |
/// sibling. | |
/// | |
/// - Parameters: | |
/// - value: The value accumulated through previous calls to this method. | |
/// The implementation should modify this value. | |
/// - nextValue: A closure that returns the next value in the sequence. | |
public static func reduce(value: inout PreferredColorSchemeKey.Value, nextValue: () -> PreferredColorSchemeKey.Value) | |
} | |
/// An indication whether a view is currently presented by another view. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Use EnvironmentValues.isPresented or EnvironmentValues.dismiss") | |
public struct PresentationMode { | |
/// Indicates whether a view is currently presented. | |
public var isPresented: Bool { get } | |
/// Dismisses the view if it is currently presented. | |
/// | |
/// If `isPresented` is false, `dismiss()` is a no-op. | |
public mutating func dismiss() | |
} | |
/// A context type for use with a preview. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol PreviewContext { | |
/// Returns the context's value for a key, or a the key's default value | |
/// if the context doesn't define a value for the key. | |
subscript<Key>(key: Key.Type) -> Key.Value where Key : PreviewContextKey { get } | |
} | |
/// A key type for a preview context. | |
/// | |
/// The default value is `nil`. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol PreviewContextKey { | |
/// The type of the value returned by the key. | |
associatedtype Value | |
/// The default value of the key. | |
static var defaultValue: Self.Value { get } | |
} | |
/// A simulator device that runs a preview. | |
/// | |
/// Create a preview device by name, like "iPhone X", or by model number, | |
/// like "iPad8,1". Use the device in a call to the ``View/previewDevice(_:)`` | |
/// modifier to set a preview device that doesn't change when you change the | |
/// run destination in Xcode: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// .previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)")) | |
/// } | |
/// } | |
/// | |
/// You can get a list of supported preview device names by using the | |
/// `xcrun` command in the Terminal app: | |
/// | |
/// % xcrun simctl list devicetypes | |
/// | |
/// Additionally, you can use the following values for macOS platform | |
/// development: | |
/// - "Mac" | |
/// - "Mac Catalyst" | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct PreviewDevice : RawRepresentable, ExpressibleByStringLiteral { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: String | |
/// Creates a new instance with the specified raw value. | |
/// | |
/// If there is no value of the type that corresponds with the specified raw | |
/// value, this initializer returns `nil`. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// print(PaperSize(rawValue: "Legal")) | |
/// // Prints "Optional("PaperSize.Legal")" | |
/// | |
/// print(PaperSize(rawValue: "Tabloid")) | |
/// // Prints "nil" | |
/// | |
/// - Parameter rawValue: The raw value to use for the new instance. | |
public init(rawValue: String) | |
/// Creates an instance initialized to the given string value. | |
/// | |
/// - Parameter value: The value of the new instance. | |
public init(stringLiteral: String) | |
/// A type that represents an extended grapheme cluster literal. | |
/// | |
/// Valid types for `ExtendedGraphemeClusterLiteralType` are `Character`, | |
/// `String`, and `StaticString`. | |
public typealias ExtendedGraphemeClusterLiteralType = String | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = String | |
/// A type that represents a string literal. | |
/// | |
/// Valid types for `StringLiteralType` are `String` and `StaticString`. | |
public typealias StringLiteralType = String | |
/// A type that represents a Unicode scalar literal. | |
/// | |
/// Valid types for `UnicodeScalarLiteralType` are `Unicode.Scalar`, | |
/// `Character`, `String`, and `StaticString`. | |
public typealias UnicodeScalarLiteralType = String | |
} | |
/// A size constraint for a preview. | |
/// | |
/// Customize the layout of a preview by providing one of these values to | |
/// the ``View/previewLayout(_:)`` modifier. For example, you can tell the | |
/// preview to take up only the amount of space that the view requires | |
/// with ``PreviewLayout/sizeThatFits``: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// .previewLayout(.sizeThatFits) | |
/// } | |
/// } | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public enum PreviewLayout { | |
/// Center the preview in a container the size of the device on which the | |
/// preview is running. | |
case device | |
/// Fit the container to the size of the preview when offered the size of | |
/// the device that the preview is running on. | |
case sizeThatFits | |
/// Center the preview in a fixed size container with the given dimensions. | |
/// | |
/// - Parameters: | |
/// - width: The width of the container. | |
/// - height: The height of the container. | |
case fixed(width: CGFloat, height: CGFloat) | |
} | |
/// Platforms that can run the preview. | |
/// | |
/// Xcode infers the platform for a preview based on the currently | |
/// selected target. If you have a multiplatform target and want to | |
/// suggest a particular target for a preview, implement the | |
/// ``PreviewProvider/platform-75xu4`` computed property as a hint, | |
/// and specify one of the preview platforms: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// } | |
/// | |
/// static var platform: PreviewPlatform? { | |
/// PreviewPlatform.tvOS | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public enum PreviewPlatform { | |
/// Specifies iOS as the preview platform. | |
case iOS | |
/// Specifies macOS as the preview platform. | |
case macOS | |
/// Specifies tvOS as the preview platform. | |
case tvOS | |
/// Specifies watchOS as the preview platform. | |
case watchOS | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: PreviewPlatform, b: PreviewPlatform) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PreviewPlatform : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PreviewPlatform : Hashable { | |
} | |
/// A type that produces view previews in Xcode. | |
/// | |
/// Create an Xcode preview by declaring a structure that conforms to the | |
/// `PreviewProvider` protocol. Implement the required | |
/// ``PreviewProvider/previews-swift.type.property`` computed property, | |
/// and return the view to display: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// } | |
/// } | |
/// | |
/// Xcode statically discovers preview providers in your project and generates | |
/// previews for any providers currently open in the source editor. | |
/// Xcode generates the preview using the current run destination as a hint | |
/// for which device to display. For example, Xcode shows the following preview | |
/// if you've selected an iOS target to run on the iPhone 12 Pro Max simulator: | |
/// | |
/// ![A screenshot of the Xcode canvas previewing a circular image on an | |
/// iPhone in the portrait orientation.](PreviewProvider-1) | |
/// | |
/// When you create a new file (File > New > File) | |
/// and choose the SwiftUI view template, Xcode automatically inserts a | |
/// preview structure at the bottom of the file that you can configure. | |
/// You can also create new preview structures in an existing SwiftUI | |
/// view file by choosing Editor > Create Preview. | |
/// | |
/// Customize the preview's appearance by adding view modifiers, just like you | |
/// do when building a custom ``View``. This includes preview-specific | |
/// modifiers that let you control aspects of the preview, like the device | |
/// orientation: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// .previewInterfaceOrientation(.landscapeLeft) | |
/// } | |
/// } | |
/// | |
/// ![A screenshot of the Xcode canvas previewing a circular image on an | |
/// iPhone in the landscape left orientation.](PreviewProvider-2) | |
/// | |
/// For the complete list of preview customizations, | |
/// see <doc:Previews-in-Xcode>. | |
/// | |
/// Xcode creates different previews for each view in your preview, | |
/// so you can see variations side by side. For example, you | |
/// might want to see a view's light and dark appearances simultaneously: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// CircleImage() | |
/// .preferredColorScheme(.dark) | |
/// } | |
/// } | |
/// | |
/// Use a ``Group`` when you want to maintain different previews, but apply a | |
/// single modifier to all of them: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// Group { | |
/// CircleImage() | |
/// CircleImage() | |
/// .preferredColorScheme(.dark) | |
/// } | |
/// .previewLayout(.sizeThatFits) | |
/// } | |
/// } | |
/// | |
/// ![A screenshot of the Xcode canvas previewing a circular image twice, | |
/// once with a light appearance and once with a dark appearance. Both | |
/// previews take up only as much room as they need to fit the circular | |
/// image.](PreviewProvider-3) | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol PreviewProvider : _PreviewProvider { | |
/// The type to preview. | |
/// | |
/// When you create a preview, Swift infers this type from your | |
/// implementation of the required | |
/// ``PreviewProvider/previews-swift.type.property`` property. | |
associatedtype Previews : View | |
/// A collection of views to preview. | |
/// | |
/// Implement a computed `previews` property to indicate the content to | |
/// preview. Xcode generates a preview for each view that you list. You | |
/// can apply ``View`` modifiers to the views, like you do | |
/// when creating a custom view. For a preview, you can also use | |
/// various preview-specific modifiers that customize the preview. | |
/// For example, you can choose a specific device for the preview | |
/// by adding the ``View/previewDevice(_:)`` modifier: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// .previewDevice(PreviewDevice(rawValue: "iPad Pro (11-inch)")) | |
/// } | |
/// } | |
/// | |
/// For the full list of preview-specific modifiers, | |
/// see <doc:Previews-in-Xcode>. | |
@ViewBuilder static var previews: Self.Previews { get } | |
/// The platform on which to run the provider. | |
/// | |
/// Xcode infers the platform for a preview based on the currently | |
/// selected target. If you have a multiplatform target and want to | |
/// suggest a particular target for a preview, implement the | |
/// `platform` computed property to provide a hint, | |
/// and specify one of the ``PreviewPlatform`` values: | |
/// | |
/// struct CircleImage_Previews: PreviewProvider { | |
/// static var previews: some View { | |
/// CircleImage() | |
/// } | |
/// | |
/// static var platform: PreviewPlatform? { | |
/// PreviewPlatform.tvOS | |
/// } | |
/// } | |
/// | |
/// Xcode ignores this value unless you have a multiplatform target. | |
static var platform: PreviewPlatform? { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PreviewProvider { | |
/// The platform to run the provider on. | |
/// | |
/// This default implementation of the ``PreviewProvider/platform-75xu4`` | |
/// computed property returns `nil`. Rely on this implementation unless | |
/// you have a multiplatform target and want to suggest a particular | |
/// platform for a preview. | |
public static var platform: PreviewPlatform? { get } | |
} | |
/// A type that applies custom interaction behavior and a custom appearance to | |
/// all buttons within a view hierarchy. | |
/// | |
/// To configure the current button style for a view hierarchy, use the | |
/// ``View/buttonStyle(_:)-66fbx`` modifier. Specify a style that conforms to | |
/// `PrimitiveButtonStyle` to create a button with custom interaction | |
/// behavior. To create a button with the standard button interaction behavior | |
/// defined for each platform, use ``ButtonStyle`` instead. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol PrimitiveButtonStyle { | |
/// A view that represents the body of a button. | |
associatedtype Body : View | |
/// Creates a view that represents the body of a button. | |
/// | |
/// The system calls this method for each ``Button`` instance in a view | |
/// hierarchy where this style is the current button style. | |
/// | |
/// - Parameter configuration : The properties of the button. | |
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body | |
/// The properties of a button. | |
typealias Configuration = PrimitiveButtonStyleConfiguration | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension PrimitiveButtonStyle where Self == BorderedProminentButtonStyle { | |
/// A button style that applies standard border prominent artwork based on | |
/// the button's context. | |
/// | |
/// To apply this style to a button, or to a view that contains buttons, use | |
/// the ``View/buttonStyle(_:)-66fbx`` modifier. | |
public static var borderedProminent: BorderedProminentButtonStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PrimitiveButtonStyle where Self == PlainButtonStyle { | |
/// A button style that doesn't style or decorate its content while idle, | |
/// but may apply a visual effect to indicate the pressed, focused, or | |
/// enabled state of the button. | |
/// | |
/// To apply this style to a button, or to a view that contains buttons, use | |
/// the ``View/buttonStyle(_:)-66fbx`` modifier. | |
public static var plain: PlainButtonStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension PrimitiveButtonStyle where Self == DefaultButtonStyle { | |
/// The default button style, based on the button's context. | |
/// | |
/// If you create a button directly on a blank canvas, the style varies by | |
/// platform. iOS uses the borderless button style by default, whereas macOS, | |
/// tvOS, and watchOS use the bordered button style. | |
/// | |
/// If you create a button inside a container, like a ``List``, the style | |
/// resolves to the recommended style for buttons inside that container for | |
/// that specific platform. | |
/// | |
/// You can override a button's style. To apply the default style to a | |
/// button, or to a view that contains buttons, use the | |
/// ``View/buttonStyle(_:)-66fbx`` modifier. | |
public static var automatic: DefaultButtonStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, watchOS 8.0, *) | |
@available(tvOS, unavailable) | |
extension PrimitiveButtonStyle where Self == BorderlessButtonStyle { | |
/// A button style that doesn't apply a border. | |
/// | |
/// To apply this style to a button, or to a view that contains buttons, use | |
/// the ``View/buttonStyle(_:)-66fbx`` modifier. | |
public static var borderless: BorderlessButtonStyle { get } | |
} | |
@available(iOS 15.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
extension PrimitiveButtonStyle where Self == BorderedButtonStyle { | |
/// A button style that applies standard border artwork based on the | |
/// button's context. | |
/// | |
/// To apply this style to a button, or to a view that contains buttons, use | |
/// the ``View/buttonStyle(_:)-66fbx`` modifier. | |
public static var bordered: BorderedButtonStyle { get } | |
} | |
/// The properties of a button. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct PrimitiveButtonStyleConfiguration { | |
/// A type-erased label of a button. | |
public struct Label : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// An optional semantic role describing the button's purpose. | |
/// | |
/// A value of `nil` means that the Button has no assigned role. If the | |
/// button does have a role, use it to make adjustments to the button's | |
/// appearance. The following example shows a custom style that uses | |
/// bold text when the role is ``ButtonRole/cancel``, | |
/// ``ShapeStyle/red`` text when the role is ``ButtonRole/destructive``, | |
/// and adds no special styling otherwise: | |
/// | |
/// struct MyButtonStyle: PrimitiveButtonStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// configuration.label | |
/// .onTapGesture { | |
/// configuration.trigger() | |
/// } | |
/// .font( | |
/// configuration.role == .cancel ? .title2.bold() : .title2) | |
/// .foregroundColor( | |
/// configuration.role == .destructive ? Color.red : nil) | |
/// } | |
/// } | |
/// | |
/// You can create one of each button using this style to see the effect: | |
/// | |
/// VStack(spacing: 20) { | |
/// Button("Cancel", role: .cancel) {} | |
/// Button("Delete", role: .destructive) {} | |
/// Button("Continue") {} | |
/// } | |
/// .buttonStyle(MyButtonStyle()) | |
/// | |
/// ![A screenshot of three buttons stacked vertically. The first says | |
/// Cancel in black, bold letters. The second says Delete in red, regular | |
/// weight letters. The third says Continue in black, regular weight | |
/// letters.](PrimitiveButtonStyleConfiguration-role-1) | |
public let role: ButtonRole? | |
/// A view that describes the effect of calling the button's action. | |
public let label: PrimitiveButtonStyleConfiguration.Label | |
/// Performs the button's action. | |
public func trigger() | |
} | |
/// A view that shows the progress towards completion of a task. | |
/// | |
/// Use a progress view to show that a task is making progress towards | |
/// completion. A progress view can show both determinate (percentage complete) | |
/// and indeterminate (progressing or not) types of progress. | |
/// | |
/// Create a determinate progress view by initializing a `ProgressView` with | |
/// a binding to a numeric value that indicates the progress, and a `total` | |
/// value that represents completion of the task. By default, the progress is | |
/// `0.0` and the total is `1.0`. | |
/// | |
/// The example below uses the state property `progress` to show progress in | |
/// a determinate `ProgressView`. The progress view uses its default total of | |
/// `1.0`, and because `progress` starts with an initial value of `0.5`, | |
/// the progress view begins half-complete. A "More" button below the progress | |
/// view allows the user to increment the progress in 5% increments: | |
/// | |
/// @State private var progress = 0.5 | |
/// | |
/// VStack { | |
/// ProgressView(value: progress) | |
/// Button("More", action: { progress += 0.05 }) | |
/// } | |
/// | |
/// To create an indeterminate progress view, use an initializer that doesn't | |
/// take a progress value: | |
/// | |
/// var body: some View { | |
/// ProgressView() | |
/// } | |
/// | |
/// ### Styling Progress Views | |
/// | |
/// You can customize the appearance and interaction of progress views by | |
/// creating styles that conform to the ``ProgressViewStyle`` protocol. To set a | |
/// specific style for all progress view instances within a view, use the | |
/// ``View/progressViewStyle(_:)`` modifier. In the following example, a custom | |
/// style adds a dark blue shadow to all progress views within the enclosing | |
/// ``VStack``: | |
/// | |
/// struct ShadowedProgressViews: View { | |
/// var body: some View { | |
/// VStack { | |
/// ProgressView(value: 0.25) | |
/// ProgressView(value: 0.75) | |
/// } | |
/// .progressViewStyle(DarkBlueShadowProgressViewStyle()) | |
/// } | |
/// } | |
/// | |
/// struct DarkBlueShadowProgressViewStyle: ProgressViewStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// ProgressView(configuration) | |
/// .shadow(color: Color(red: 0, green: 0, blue: 0.6), | |
/// radius: 4.0, x: 1.0, y: 2.0) | |
/// } | |
/// } | |
/// | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct ProgressView<Label, CurrentValueLabel> : View where Label : View, CurrentValueLabel : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressView where CurrentValueLabel == EmptyView { | |
/// Creates a progress view for showing indeterminate progress, without a | |
/// label. | |
public init() where Label == EmptyView | |
/// Creates a progress view for showing indeterminate progress that displays | |
/// a custom label. | |
/// | |
/// - Parameters: | |
/// - label: A view builder that creates a view that describes the task | |
/// in progress. | |
public init(@ViewBuilder label: () -> Label) | |
/// Creates a progress view for showing indeterminate progress that | |
/// generates its label from a localized string. | |
/// | |
/// This initializer creates a ``Text`` view on your behalf, and treats the | |
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See | |
/// ``Text`` for more information about localizing strings. To initialize a | |
/// indeterminate progress view with a string variable, use | |
/// the corresponding initializer that takes a `StringProtocol` instance. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the progress view's localized title that | |
/// describes the task in progress. | |
public init(_ titleKey: LocalizedStringKey) where Label == Text | |
/// Creates a progress view for showing indeterminate progress that | |
/// generates its label from a string. | |
/// | |
/// - Parameters: | |
/// - title: A string that describes the task in progress. | |
/// | |
/// This initializer creates a ``Text`` view on your behalf, and treats the | |
/// title similar to ``Text/init(verbatim:)``. See ``Text`` for more | |
/// information about localizing strings. To initialize a progress view with | |
/// a localized string key, use the corresponding initializer that takes a | |
/// `LocalizedStringKey` instance. | |
public init<S>(_ title: S) where Label == Text, S : StringProtocol | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressView { | |
/// Creates a progress view for showing determinate progress. | |
/// | |
/// If the value is non-`nil`, but outside the range of `0.0` through | |
/// `total`, the progress view pins the value to those limits, rounding to | |
/// the nearest possible bound. A value of `nil` represents indeterminate | |
/// progress, in which case the progress view ignores `total`. | |
/// | |
/// - Parameters: | |
/// - value: The completed amount of the task to this point, in a range | |
/// of `0.0` to `total`, or `nil` if the progress is indeterminate. | |
/// - total: The full amount representing the complete scope of the | |
/// task, meaning the task is complete if `value` equals `total`. The | |
/// default value is `1.0`. | |
public init<V>(value: V?, total: V = 1.0) where Label == EmptyView, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint | |
/// Creates a progress view for showing determinate progress, with a | |
/// custom label. | |
/// | |
/// If the value is non-`nil`, but outside the range of `0.0` through | |
/// `total`, the progress view pins the value to those limits, rounding to | |
/// the nearest possible bound. A value of `nil` represents indeterminate | |
/// progress, in which case the progress view ignores `total`. | |
/// | |
/// - Parameters: | |
/// - value: The completed amount of the task to this point, in a range | |
/// of `0.0` to `total`, or `nil` if the progress is indeterminate. | |
/// - total: The full amount representing the complete scope of the | |
/// task, meaning the task is complete if `value` equals `total`. The | |
/// default value is `1.0`. | |
/// - label: A view builder that creates a view that describes the task | |
/// in progress. | |
public init<V>(value: V?, total: V = 1.0, @ViewBuilder label: () -> Label) where CurrentValueLabel == EmptyView, V : BinaryFloatingPoint | |
/// Creates a progress view for showing determinate progress, with a | |
/// custom label. | |
/// | |
/// If the value is non-`nil`, but outside the range of `0.0` through | |
/// `total`, the progress view pins the value to those limits, rounding to | |
/// the nearest possible bound. A value of `nil` represents indeterminate | |
/// progress, in which case the progress view ignores `total`. | |
/// | |
/// - Parameters: | |
/// - value: The completed amount of the task to this point, in a range | |
/// of `0.0` to `total`, or `nil` if the progress is indeterminate. | |
/// - total: The full amount representing the complete scope of the | |
/// task, meaning the task is complete if `value` equals `total`. The | |
/// default value is `1.0`. | |
/// - label: A view builder that creates a view that describes the task | |
/// in progress. | |
/// - currentValueLabel: A view builder that creates a view that | |
/// describes the level of completed progress of the task. | |
public init<V>(value: V?, total: V = 1.0, @ViewBuilder label: () -> Label, @ViewBuilder currentValueLabel: () -> CurrentValueLabel) where V : BinaryFloatingPoint | |
/// Creates a progress view for showing determinate progress that generates | |
/// its label from a localized string. | |
/// | |
/// If the value is non-`nil`, but outside the range of `0.0` through | |
/// `total`, the progress view pins the value to those limits, rounding to | |
/// the nearest possible bound. A value of `nil` represents indeterminate | |
/// progress, in which case the progress view ignores `total`. | |
/// | |
/// This initializer creates a ``Text`` view on your behalf, and treats the | |
/// localized key similar to ``Text/init(_:tableName:bundle:comment:)``. See | |
/// ``Text`` for more information about localizing strings. To initialize a | |
/// determinate progress view with a string variable, use | |
/// the corresponding initializer that takes a `StringProtocol` instance. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the progress view's localized title that | |
/// describes the task in progress. | |
/// - value: The completed amount of the task to this point, in a range | |
/// of `0.0` to `total`, or `nil` if the progress is | |
/// indeterminate. | |
/// - total: The full amount representing the complete scope of the | |
/// task, meaning the task is complete if `value` equals `total`. The | |
/// default value is `1.0`. | |
public init<V>(_ titleKey: LocalizedStringKey, value: V?, total: V = 1.0) where Label == Text, CurrentValueLabel == EmptyView, V : BinaryFloatingPoint | |
/// Creates a progress view for showing determinate progress that generates | |
/// its label from a string. | |
/// | |
/// If the value is non-`nil`, but outside the range of `0.0` through | |
/// `total`, the progress view pins the value to those limits, rounding to | |
/// the nearest possible bound. A value of `nil` represents indeterminate | |
/// progress, in which case the progress view ignores `total`. | |
/// | |
/// This initializer creates a ``Text`` view on your behalf, and treats the | |
/// title similar to ``Text/init(verbatim:)``. See ``Text`` for more | |
/// information about localizing strings. To initialize a determinate | |
/// progress view with a localized string key, use the corresponding | |
/// initializer that takes a `LocalizedStringKey` instance. | |
/// | |
/// - Parameters: | |
/// - title: The string that describes the task in progress. | |
/// - value: The completed amount of the task to this point, in a range | |
/// of `0.0` to `total`, or `nil` if the progress is | |
/// indeterminate. | |
/// - total: The full amount representing the complete scope of the | |
/// task, meaning the task is complete if `value` equals `total`. The | |
/// default value is `1.0`. | |
public init<S, V>(_ title: S, value: V?, total: V = 1.0) where Label == Text, CurrentValueLabel == EmptyView, S : StringProtocol, V : BinaryFloatingPoint | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressView { | |
/// Creates a progress view for visualizing the given progress instance. | |
/// | |
/// The progress view synthesizes a default label using the | |
/// `localizedDescription` of the given progress instance. | |
public init(_ progress: Progress) where Label == EmptyView, CurrentValueLabel == EmptyView | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressView { | |
/// Creates a progress view based on a style configuration. | |
/// | |
/// You can use this initializer within the | |
/// ``ProgressViewStyle/makeBody(configuration:)`` method of a | |
/// ``ProgressViewStyle`` to create an instance of the styled progress view. | |
/// This is useful for custom progress view styles that only modify the | |
/// current progress view style, as opposed to implementing a brand new | |
/// style. | |
/// | |
/// For example, the following style adds a dark blue shadow to the progress | |
/// view, but otherwise preserves the progress view's current style: | |
/// | |
/// struct DarkBlueShadowProgressViewStyle: ProgressViewStyle { | |
/// func makeBody(configuration: Configuration) -> some View { | |
/// ProgressView(configuration) | |
/// .shadow(color: Color(red: 0, green: 0, blue: 0.6), | |
/// radius: 4.0, x: 1.0, y: 2.0) | |
/// } | |
/// } | |
/// | |
public init(_ configuration: ProgressViewStyleConfiguration) where Label == ProgressViewStyleConfiguration.Label, CurrentValueLabel == ProgressViewStyleConfiguration.CurrentValueLabel | |
} | |
/// A type that applies standard interaction behavior to all progress views | |
/// within a view hierarchy. | |
/// | |
/// To configure the current progress view style for a view hierarchy, use the | |
/// ``View/progressViewStyle(_:)`` modifier. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol ProgressViewStyle { | |
/// A view representing the body of a progress view. | |
associatedtype Body : View | |
/// Creates a view representing the body of a progress view. | |
/// | |
/// - Parameter configuration: The properties of the progress view being | |
/// created. | |
/// | |
/// The view hierarchy calls this method for each progress view where this | |
/// style is the current progress view style. | |
/// | |
/// - Parameter configuration: The properties of the progress view, such as | |
/// its preferred progress type. | |
@ViewBuilder func makeBody(configuration: Self.Configuration) -> Self.Body | |
/// A type alias for the properties of a progress view instance. | |
typealias Configuration = ProgressViewStyleConfiguration | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressViewStyle where Self == DefaultProgressViewStyle { | |
/// The default progress view style in the current context of the view being | |
/// styled. | |
/// | |
/// The default style represents the recommended style based on the original | |
/// initialization parameters of the progress view, and the progress view's | |
/// context within the view hierarchy. | |
public static var automatic: DefaultProgressViewStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressViewStyle where Self == CircularProgressViewStyle { | |
/// A progress view that visually indicates its progress using a circular | |
/// gauge. | |
public static var circular: CircularProgressViewStyle { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ProgressViewStyle where Self == LinearProgressViewStyle { | |
/// A progress view that visually indicates its progress using a horizontal | |
/// bar. | |
public static var linear: LinearProgressViewStyle { get } | |
} | |
/// The properties of a progress view instance. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct ProgressViewStyleConfiguration { | |
/// A type-erased label describing the task represented by the progress | |
/// view. | |
public struct Label : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A type-erased label that describes the current value of a progress view. | |
public struct CurrentValueLabel : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// The completed fraction of the task represented by the progress view, | |
/// from `0.0` (not yet started) to `1.0` (fully complete), or `nil` if the | |
/// progress is indeterminate. | |
public let fractionCompleted: Double? | |
/// A view that describes the task represented by the progress view. | |
/// | |
/// If `nil`, then the task is self-evident from the surrounding context, | |
/// and the style does not need to provide any additional description. | |
/// | |
/// If the progress view is defined using a `Progress` instance, then this | |
/// label is equivalent to its `localizedDescription`. | |
public var label: ProgressViewStyleConfiguration.Label? | |
/// A view that describes the current value of a progress view. | |
/// | |
/// If `nil`, then the value of the progress view is either self-evident | |
/// from the surrounding context or unknown, and the style does not need to | |
/// provide any additional description. | |
/// | |
/// If the progress view is defined using a `Progress` instance, then this | |
/// label is equivalent to its `localizedAdditionalDescription`. | |
public var currentValueLabel: ProgressViewStyleConfiguration.CurrentValueLabel? | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct ProjectionTransform { | |
public var m11: CGFloat | |
public var m12: CGFloat | |
public var m13: CGFloat | |
public var m21: CGFloat | |
public var m22: CGFloat | |
public var m23: CGFloat | |
public var m31: CGFloat | |
public var m32: CGFloat | |
public var m33: CGFloat | |
@inlinable public init() | |
@inlinable public init(_ m: CGAffineTransform) | |
@inlinable public init(_ m: CATransform3D) | |
@inlinable public var isIdentity: Bool { get } | |
@inlinable public var isAffine: Bool { get } | |
public mutating func invert() -> Bool | |
public func inverted() -> ProjectionTransform | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ProjectionTransform : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: ProjectionTransform, b: ProjectionTransform) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ProjectionTransform { | |
@inlinable public func concatenating(_ rhs: ProjectionTransform) -> ProjectionTransform | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ProjectionTransform : Sendable { | |
} | |
/// A type indicating the prominence of a view hierarchy. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public enum Prominence { | |
/// The standard prominence. | |
case standard | |
/// An increased prominence. | |
/// | |
/// - Note: Not all views will react to increased prominence. | |
case increased | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Prominence, b: Prominence) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Prominence : Equatable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Prominence : Hashable { | |
} | |
/// A radial gradient. | |
/// | |
/// The gradient applies the color function as the distance from a center | |
/// point, scaled to fit within the defined start and end radii. The | |
/// gradient maps the unit space center point into the bounding rectangle of | |
/// each shape filled with the gradient. | |
/// | |
/// When using a radial gradient as a shape style, you can also use | |
/// ``ShapeStyle/radialGradient(_:center:startRadius:endRadius:)``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct RadialGradient : ShapeStyle, View { | |
/// Creates a radial gradient from a base gradient. | |
public init(gradient: Gradient, center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) | |
/// Creates a radial gradient from a collection of colors. | |
public init(colors: [Color], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) | |
/// Creates a radial gradient from a collection of color stops. | |
public init(stops: [Gradient.Stop], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
/// A rectangular shape aligned inside the frame of the view containing it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Rectangle : Shape { | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in rect: CGRect) -> Path | |
@inlinable public init() | |
/// The type defining the data to animate. | |
public typealias AnimatableData = EmptyAnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Rectangle : InsettableShape { | |
/// Returns `self` inset by `amount`. | |
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape | |
/// The type of the inset shape. | |
public typealias InsetShape = some InsettableShape | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Rectangle : Sendable { | |
} | |
/// The reasons to apply a redaction to data displayed on screen. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct RedactionReasons : OptionSet { | |
/// The raw value. | |
public let rawValue: Int | |
/// Creates a new set from a raw value. | |
/// | |
/// - Parameter rawValue: The raw value with which to create the | |
/// reasons for redaction. | |
public init(rawValue: Int) | |
/// Displayed data should appear as generic placeholders. | |
/// | |
/// Text and images will be automatically masked to appear as | |
/// generic placeholders, though maintaining their original size and shape. | |
/// Use this to create a placeholder UI without directly exposing | |
/// placeholder data to users. | |
public static let placeholder: RedactionReasons | |
/// Displayed data should be obscured to protect private information. | |
/// | |
/// Views marked with `privacySensitive` will be automatically redacted | |
/// using a standard styling. To apply a custom treatment the redaction | |
/// reason can be read out of the environment. | |
/// | |
/// struct BankingContentView: View { | |
/// @Environment(\.redactionReasons) var redactionReasons | |
/// | |
/// var body: some View { | |
/// if redactionReasons.contains(.privacy) { | |
/// FullAppCover() | |
/// } else { | |
/// AppContent() | |
/// } | |
/// } | |
/// } | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static let privacy: RedactionReasons | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = RedactionReasons | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = RedactionReasons | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int | |
} | |
/// A document model definition used to serialize reference type documents to | |
/// and from file contents. | |
/// | |
/// Conformance to `ReferenceFileDocument` is expected to be thread-safe, and | |
/// deserialization and serialization will be done on a background thread. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public protocol ReferenceFileDocument : ObservableObject { | |
/// A type of the document snapshot that can be used for serialization | |
/// in parallel to the main document being editable. | |
/// | |
/// - See Also: `snapshot(contentType:)` | |
associatedtype Snapshot | |
/// The types the document is able to open. | |
static var readableContentTypes: [UTType] { get } | |
/// The types the document is able to save or export to. | |
/// | |
/// Defaults to `readableContentTypes`. | |
static var writableContentTypes: [UTType] { get } | |
/// Initialize self by reading from the contents of a given `ReadConfiguration`. | |
init(configuration: Self.ReadConfiguration) throws | |
/// The configuration for reading document contents. | |
typealias ReadConfiguration = FileDocumentReadConfiguration | |
/// Create a snapshot of the current state of the document, which will be | |
/// used for serialization while `self` becomes editable by the user. | |
/// | |
/// When saving a `ReferenceFileDocument`, edits to the document are blocked | |
/// until snapshot with a copy of any mutable references can be created. | |
/// Once the snapshot is created, the document becomes editable in parallel | |
/// to the snapshot being serialized using `write(snapshot:to:contentType:)`. | |
/// | |
/// - Parameter contentType: The content type being written, for which the | |
/// snapshot should be created. | |
func snapshot(contentType: UTType) throws -> Self.Snapshot | |
/// Serialize the snapshot to file contents for a specified `type`. | |
/// | |
/// - Parameters: | |
/// - snapshot: The snapshot of the document containing the state required | |
/// to be saved. | |
/// - configuration: The configuration for the current document contents. | |
/// | |
/// - Returns: The destination to serialize the document contents to. The | |
/// value can be a newly created `FileWrapper` or an updated `FileWrapper` | |
/// of the one provided in `configuration`. | |
func fileWrapper(snapshot: Self.Snapshot, configuration: Self.WriteConfiguration) throws -> FileWrapper | |
/// The configurations for serializing document contents. | |
typealias WriteConfiguration = FileDocumentWriteConfiguration | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ReferenceFileDocument { | |
/// The types the document is able to save or export to. | |
/// | |
/// Defaults to `readableContentTypes`. | |
public static var writableContentTypes: [UTType] { get } | |
} | |
/// The properties of an open reference file document. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct ReferenceFileDocumentConfiguration<Document> where Document : ReferenceFileDocument { | |
/// The current document model. | |
/// | |
/// Changes to the document are observed and on change dirty the document | |
/// state for resaving. Undo actions are not automatically registered and | |
/// need to be done explicitly. | |
public var document: Document | |
public var $document: ObservedObject<Document>.Wrapper { get } | |
/// The url of the open file document. | |
public var fileURL: URL? | |
/// Whether the document is able to be edited. | |
/// | |
/// This can return `false` if the document is in viewing mode or if the | |
/// file is unable to be written to. | |
public var isEditable: Bool | |
} | |
/// An action that users can initiate to refresh model data. | |
/// | |
/// The `RefreshAction` instance in an app's ``Environment`` contains | |
/// a handler that you can set to customize how a view | |
/// refreshes its data model. | |
/// Use the ``View/refreshable(action:)`` modifier to set this action. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct RefreshAction { | |
/// Trigger a refresh action. | |
/// | |
/// This async function is stored in the environment | |
/// ``EnvironmentValues/refresh`` and can be set with the modifier | |
/// ``View/refreshable(action:)``. Call this function to initiate a refresh action. | |
public func callAsFunction() async | |
} | |
/// A shape with a rotation transform applied to it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct RotatedShape<Content> : Shape where Content : Shape { | |
public var shape: Content | |
public var angle: Angle | |
public var anchor: UnitPoint | |
@inlinable public init(shape: Content, angle: Angle, anchor: UnitPoint = .center) | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in rect: CGRect) -> Path | |
/// An indication of how to style a shape. | |
/// | |
/// SwiftUI looks at a shape's role when deciding how to apply a | |
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a | |
/// default implementation with a value of ``ShapeRole/fill``. If you | |
/// create a composite shape, you can provide an override of this property | |
/// to return another value, if appropriate. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var role: ShapeRole { get } | |
/// The type defining the data to animate. | |
public typealias AnimatableData = AnimatablePair<Content.AnimatableData, AnimatablePair<Angle.AnimatableData, UnitPoint.AnimatableData>> | |
/// The data to animate. | |
public var animatableData: RotatedShape<Content>.AnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension RotatedShape : InsettableShape where Content : InsettableShape { | |
/// Returns `self` inset by `amount`. | |
@inlinable public func inset(by amount: CGFloat) -> RotatedShape<Content.InsetShape> | |
/// The type of the inset shape. | |
public typealias InsetShape = RotatedShape<Content.InsetShape> | |
} | |
/// A gesture that recognizes a rotation motion and tracks the angle of the | |
/// rotation. | |
/// | |
/// A rotation gesture tracks how a rotation event sequence changes. To | |
/// recognize a rotation gesture on a view, create and configure the gesture, | |
/// and then add it to the view using the ``View/gesture(_:including:)`` | |
/// modifier. | |
/// | |
/// Add a rotation gesture to a ``Rectangle`` and apply a rotation effect: | |
/// | |
/// struct RotationGestureView: View { | |
/// @State var angle = Angle(degrees: 0.0) | |
/// | |
/// var rotation: some Gesture { | |
/// RotationGesture() | |
/// .onChanged { angle in | |
/// self.angle = angle | |
/// } | |
/// } | |
/// | |
/// var body: some View { | |
/// Rectangle() | |
/// .frame(width: 200, height: 200, alignment: .center) | |
/// .rotationEffect(self.angle) | |
/// .gesture(rotation) | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct RotationGesture : Gesture { | |
/// The minimum delta required before the gesture succeeds. | |
public var minimumAngleDelta: Angle | |
/// Creates a rotation gesture with a minimum delta for the gesture to | |
/// start. | |
/// | |
/// - Parameter minimumAngleDelta: The minimum delta required before the | |
/// gesture starts. The default value is a one-degree angle. | |
public init(minimumAngleDelta: Angle = .degrees(1)) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
/// The type representing the gesture's value. | |
public typealias Value = Angle | |
} | |
/// A text field style with a system-defined rounded border. | |
/// | |
/// Do not use this type directly. Instead, use ``TextFieldStyle/roundedBorder``. | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct RoundedBorderTextFieldStyle : TextFieldStyle { | |
public init() | |
} | |
/// Defines the shape of a rounded rectangle's corners. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public enum RoundedCornerStyle { | |
/// Quarter-circle rounded rect corners. | |
case circular | |
/// Continuous curvature rounded rect corners. | |
case continuous | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: RoundedCornerStyle, b: RoundedCornerStyle) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension RoundedCornerStyle : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension RoundedCornerStyle : Hashable { | |
} | |
/// A rectangular shape with rounded corners, aligned inside the frame of the | |
/// view containing it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct RoundedRectangle : Shape { | |
public var cornerSize: CGSize | |
public var style: RoundedCornerStyle | |
@inlinable public init(cornerSize: CGSize, style: RoundedCornerStyle = .circular) | |
@inlinable public init(cornerRadius: CGFloat, style: RoundedCornerStyle = .circular) | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in rect: CGRect) -> Path | |
/// The data to animate. | |
public var animatableData: CGSize.AnimatableData | |
/// The type defining the data to animate. | |
public typealias AnimatableData = CGSize.AnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension RoundedRectangle : InsettableShape { | |
/// Returns `self` inset by `amount`. | |
@inlinable public func inset(by amount: CGFloat) -> some InsettableShape | |
/// The type of the inset shape. | |
public typealias InsetShape = some InsettableShape | |
} | |
/// A set of symbolic safe area regions. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@frozen public struct SafeAreaRegions : OptionSet { | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: UInt | |
/// Creates a new option set from the given raw value. | |
/// | |
/// This initializer always succeeds, even if the value passed as `rawValue` | |
/// exceeds the static properties declared as part of the option set. This | |
/// example creates an instance of `ShippingOptions` with a raw value beyond | |
/// the highest element, with a bit mask that effectively contains all the | |
/// declared static members. | |
/// | |
/// let extraOptions = ShippingOptions(rawValue: 255) | |
/// print(extraOptions.isStrictSuperset(of: .all)) | |
/// // Prints "true" | |
/// | |
/// - Parameter rawValue: The raw value of the option set to create. Each bit | |
/// of `rawValue` potentially represents an element of the option set, | |
/// though raw values may include bits that are not defined as distinct | |
/// values of the `OptionSet` type. | |
@inlinable public init(rawValue: UInt) | |
/// The safe area defined by the device and containers within the | |
/// user interface, including elements such as top and bottom bars. | |
public static let container: SafeAreaRegions | |
/// The safe area matching the current extent of any software | |
/// keyboard displayed over the view content. | |
public static let keyboard: SafeAreaRegions | |
/// All safe area regions. | |
public static let all: SafeAreaRegions | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = SafeAreaRegions | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = SafeAreaRegions | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = UInt | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SafeAreaRegions : Sendable { | |
} | |
/// A dynamic property that scales a numeric value. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@propertyWrapper public struct ScaledMetric<Value> : DynamicProperty where Value : BinaryFloatingPoint { | |
/// Creates the scaled metric with an unscaled value and a text style to | |
/// scale relative to. | |
public init(wrappedValue: Value, relativeTo textStyle: Font.TextStyle) | |
/// Creates the scaled metric with an unscaled value using the default | |
/// scaling. | |
public init(wrappedValue: Value) | |
/// The value scaled based on the current environment. | |
public var wrappedValue: Value { get } | |
} | |
/// A shape with a scale transform applied to it. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct ScaledShape<Content> : Shape where Content : Shape { | |
public var shape: Content | |
public var scale: CGSize | |
public var anchor: UnitPoint | |
@inlinable public init(shape: Content, scale: CGSize, anchor: UnitPoint = .center) | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
public func path(in rect: CGRect) -> Path | |
/// An indication of how to style a shape. | |
/// | |
/// SwiftUI looks at a shape's role when deciding how to apply a | |
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a | |
/// default implementation with a value of ``ShapeRole/fill``. If you | |
/// create a composite shape, you can provide an override of this property | |
/// to return another value, if appropriate. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var role: ShapeRole { get } | |
/// The type defining the data to animate. | |
public typealias AnimatableData = AnimatablePair<Content.AnimatableData, AnimatablePair<CGSize.AnimatableData, UnitPoint.AnimatableData>> | |
/// The data to animate. | |
public var animatableData: ScaledShape<Content>.AnimatableData | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body | |
} | |
/// A part of an app's user interface with a life cycle managed by the | |
/// system. | |
/// | |
/// You create an ``SwiftUI/App`` by combining one or more instances | |
/// that conform to the `Scene` protocol in the app's | |
/// ``SwiftUI/App/body-swift.property``. You can use the primitive scenes that | |
/// SwiftUI provides, like ``SwiftUI/WindowGroup``, along with custom scenes | |
/// that you compose from other scenes. To create a custom scene, declare a | |
/// type that conforms to the `Scene` protocol. Implement the required | |
/// ``SwiftUI/Scene/body-swift.property`` computed property and provide the | |
/// content for your custom scene: | |
/// | |
/// struct MyScene: Scene { | |
/// var body: some Scene { | |
/// WindowGroup { | |
/// MyRootView() | |
/// } | |
/// } | |
/// } | |
/// | |
/// A scene acts as a container for a view hierarchy that you want to display | |
/// to the user. The system decides when and how to present the view hierarchy | |
/// in the user interface in a way that's platform-appropriate and dependent | |
/// on the current state of the app. For example, for the window group shown | |
/// above, the system lets the user create or remove windows that contain | |
/// `MyRootView` on platforms like macOS and iPadOS. On other platforms, the | |
/// same view hierarchy might consume the entire display when active. | |
/// | |
/// Read the ``SwiftUI/EnvironmentValues/scenePhase`` environment | |
/// value from within a scene or one of its views to check whether a scene is | |
/// active or in some other state. You can create a property that contains the | |
/// scene phase, which is one of the values in the ``SwiftUI/ScenePhase`` | |
/// enumeration, using the ``SwiftUI/Environment`` attribute: | |
/// | |
/// struct MyScene: Scene { | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// | |
/// // ... | |
/// } | |
/// | |
/// The `Scene` protocol provides scene modifiers, defined as protocol methods | |
/// with default implementations, that you use to configure a scene. For | |
/// example, you can use the ``SwiftUI/Scene/onChange(of:perform:)`` modifier to | |
/// trigger an action when a value changes. The following code empties a cache | |
/// when all of the scenes in the window group have moved to the background: | |
/// | |
/// struct MyScene: Scene { | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// @StateObject private var cache = DataCache() | |
/// | |
/// var body: some Scene { | |
/// WindowGroup { | |
/// MyRootView() | |
/// } | |
/// .onChange(of: scenePhase) { newScenePhase in | |
/// if newScenePhase == .background { | |
/// cache.empty() | |
/// } | |
/// } | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol Scene { | |
/// The type of scene that represents the body of this scene. | |
/// | |
/// When you create a custom scene, Swift infers this type from your | |
/// implementation of the required ``SwiftUI/Scene/body-swift.property`` | |
/// property. | |
associatedtype Body : Scene | |
/// The content and behavior of the scene. | |
/// | |
/// For any scene that you create, provide a computed `body` property that | |
/// defines the scene as a composition of other scenes. You can assemble a | |
/// scene from primitive scenes that SwiftUI provides, as well as other | |
/// scenes that you've defined. | |
/// | |
/// Swift infers the scene's ``SwiftUI/Scene/Body-swift.associatedtype`` | |
/// associated type based on the contents of the `body` property. | |
@SceneBuilder var body: Self.Body { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Scene { | |
/// Adds an action to perform when the given value changes. | |
/// | |
/// Use this modifier to trigger a side effect when a value changes, like | |
/// the value associated with an ``SwiftUI/Environment`` key or a | |
/// ``SwiftUI/Binding``. For example, you can clear a cache when you notice | |
/// that a scene moves to the background: | |
/// | |
/// struct MyScene: Scene { | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// @StateObject private var cache = DataCache() | |
/// | |
/// var body: some Scene { | |
/// WindowGroup { | |
/// MyRootView() | |
/// } | |
/// .onChange(of: scenePhase) { newScenePhase in | |
/// if newScenePhase == .background { | |
/// cache.empty() | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
/// The system calls the `action` closure on the main thread, so avoid | |
/// long-running tasks in the closure. If you need to perform such tasks, | |
/// dispatch to a background queue: | |
/// | |
/// .onChange(of: scenePhase) { newScenePhase in | |
/// if newScenePhase == .background { | |
/// DispatchQueue.global(qos: .background).async { | |
/// // ... | |
/// } | |
/// } | |
/// } | |
/// | |
/// The system passes the new value into the closure. If you need the old | |
/// value, capture it in the closure. | |
/// | |
/// - Parameters: | |
/// - value: The value to check when determining whether to run the | |
/// closure. The value must conform to the | |
/// <doc://com.apple.documentation/documentation/Swift/Equatable> | |
/// protocol. | |
/// - action: A closure to run when the value changes. The closure | |
/// provides a single `newValue` parameter that indicates the changed | |
/// value. | |
/// | |
/// - Returns: A scene that triggers an action in response to a change. | |
@inlinable public func onChange<V>(of value: V, perform action: @escaping (_ newValue: V) -> Void) -> some Scene where V : Equatable | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Scene { | |
/// Adds commands to the scene. | |
/// | |
/// Commands are realized in different ways on different platforms. On | |
/// macOS, the main menu uses the available command menus and groups to | |
/// organize its main menu items. Each menu is represented as a top-level | |
/// menu bar menu, and each command group has a corresponding set of menu | |
/// items in one of the top-level menus, delimited by separator menu items. | |
/// | |
/// On iPadOS, commands with keyboard shortcuts are exposed in the shortcut | |
/// discoverability HUD that users see when they hold down the Command (⌘) | |
/// key. | |
public func commands<Content>(@CommandsBuilder content: () -> Content) -> some Scene where Content : Commands | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Scene { | |
/// The default store used by `AppStorage` contained within the scene and | |
/// its view content. | |
/// | |
/// If unspecified, the default store for a view hierarchy is | |
/// `UserDefaults.standard`, but can be set a to a custom one. For example, | |
/// sharing defaults between an app and an extension can override the | |
/// default store to one created with `UserDefaults.init(suiteName:_)`. | |
/// | |
/// - Parameter store: The user defaults to use as the default | |
/// store for `AppStorage`. | |
public func defaultAppStorage(_ store: UserDefaults) -> some Scene | |
} | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Scene { | |
/// Specifies a modifier to indicate if this Scene can be used | |
/// when creating a new Scene for the received External Event. | |
/// | |
/// This modifier is only supported for WindowGroup Scene types. | |
/// | |
/// For DocumentGroups, the received External Event must have a URL | |
/// for the DocumentGroup to be considered. (Either via openURL, or | |
/// the webPageURL property of an NSUserActivity). The UTI for the URL | |
/// is implicitly matched against the DocumentGroup's supported types. | |
/// | |
/// If the modifier evaluates to true, an instance of the | |
/// Scene will be used. | |
/// | |
/// If the modifier evaluates to false, on macOS the Scene | |
/// will not be used even if no other Scenes are available. | |
/// This case is considered an error. On iOS, the first Scene | |
/// specified in the body property for the App will be used. | |
/// | |
/// If no modifier is set, the Scene will be used if all | |
/// other WindowGroups with a modifier evaluate to false. | |
/// | |
/// On platforms that only allow a single Window/Scene, this method is | |
/// ignored. | |
/// | |
/// - Parameter matching: A Set of Strings that are checked to see | |
/// if they are contained in the targetContentIdenfifier. The empty Set | |
/// and empty Strings never match. The String value "*" always matches. | |
public func handlesExternalEvents(matching conditions: Set<String>) -> some Scene | |
} | |
/// A result builder for composing a collection of scenes into a single | |
/// composite scene. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@resultBuilder public struct SceneBuilder { | |
/// Passes a single scene written as a child scene through unmodified. | |
public static func buildBlock<Content>(_ content: Content) -> Content where Content : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1>(_ c0: C0, _ c1: C1) -> some Scene where C0 : Scene, C1 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2>(_ c0: C0, _ c1: C1, _ c2: C2) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3, C4>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3, C4, C5>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene, C7 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene, C7 : Scene, C8 : Scene | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneBuilder { | |
public static func buildBlock<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9>(_ c0: C0, _ c1: C1, _ c2: C2, _ c3: C3, _ c4: C4, _ c5: C5, _ c6: C6, _ c7: C7, _ c8: C8, _ c9: C9) -> some Scene where C0 : Scene, C1 : Scene, C2 : Scene, C3 : Scene, C4 : Scene, C5 : Scene, C6 : Scene, C7 : Scene, C8 : Scene, C9 : Scene | |
} | |
/// An indication of a scene's operational state. | |
/// | |
/// The system moves your app's ``Scene`` instances through phases that reflect | |
/// a scene's operational state. You can trigger actions when the phase changes. | |
/// Read the current phase by observing the ``EnvironmentValues/scenePhase`` | |
/// value in the ``Environment``: | |
/// | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// | |
/// How you interpret the value depends on where it's read from. | |
/// If you read the phase from inside a ``View`` instance, you obtain a value | |
/// that reflects the phase of the scene that contains the view. The following | |
/// example uses the ``SwiftUI/View/onChange(of:perform:)`` method to enable | |
/// a timer whenever the enclosing scene enters the ``ScenePhase/active`` phase | |
/// and disable the timer when entering any other phase: | |
/// | |
/// struct MyView: View { | |
/// @ObservedObject var model: DataModel | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// | |
/// var body: some View { | |
/// TimerView() | |
/// .onChange(of: scenePhase) { phase in | |
/// model.isTimerRunning = (phase == .active) | |
/// } | |
/// } | |
/// } | |
/// | |
/// If you read the phase from within an ``App`` instance, you obtain an | |
/// aggregate value that reflects the phases of all the scenes in your app. The | |
/// app reports a value of ``ScenePhase/active`` if any scene is active, or a | |
/// value of ``ScenePhase/inactive`` when no scenes are active. This includes | |
/// multiple scene instances created from a single scene declaration; for | |
/// example, from a ``WindowGroup``. When an app enters the | |
/// ``ScenePhase/background`` phase, expect the app to terminate soon after. | |
/// You can use that opportunity to free any resources: | |
/// | |
/// @main | |
/// struct MyApp: App { | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// | |
/// var body: some Scene { | |
/// WindowGroup { | |
/// MyRootView() | |
/// } | |
/// .onChange(of: scenePhase) { phase in | |
/// if phase == .background { | |
/// // Perform cleanup when all scenes within | |
/// // MyApp go to the background. | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
/// If you read the phase from within a custom ``Scene`` instance, the value | |
/// similarly reflects an aggregation of all the scenes that make up the custom | |
/// scene: | |
/// | |
/// struct MyScene: Scene { | |
/// @Environment(\.scenePhase) private var scenePhase | |
/// | |
/// var body: some Scene { | |
/// WindowGroup { | |
/// MyRootView() | |
/// } | |
/// .onChange(of: scenePhase) { phase in | |
/// if phase == .background { | |
/// // Perform cleanup when all scenes within | |
/// // MyScene go to the background. | |
/// } | |
/// } | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public enum ScenePhase : Comparable { | |
/// The scene isn't currently visible in the UI. | |
/// | |
/// Do as little as possible in a scene that's in the `background` phase. | |
/// The `background` phase can precede termination, so do any cleanup work | |
/// immediately upon entering this state. For example, close any open files | |
/// and network connections. However, a scene can also return to the | |
/// ``ScenePhase/active`` phase from the background. | |
/// | |
/// Expect an app that enters the `background` phase to terminate. | |
case background | |
/// The scene is in the foreground but should pause its work. | |
/// | |
/// A scene in this phase doesn't receive events and should pause | |
/// timers and free any unnecessary resources. The scene might be completely | |
/// hidden in the user interface or otherwise unavailable to the user. | |
/// In macOS, scenes only pass through this phase temporarily on their way | |
/// to the ``ScenePhase/background`` phase. | |
/// | |
/// An app or custom scene in this phase contains no scene instances in the | |
/// ``ScenePhase/active`` phase. | |
case inactive | |
/// The scene is in the foreground and interactive. | |
/// | |
/// An active scene isn't necessarily front-most. For example, a macOS | |
/// window might be active even if it doesn't currently have focus. | |
/// Nevertheless, all scenes should operate normally in this phase. | |
/// | |
/// An app or custom scene in this phase contains at least one active scene | |
/// instance. | |
case active | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: ScenePhase, b: ScenePhase) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// Returns a Boolean value indicating whether the value of the first | |
/// argument is less than that of the second argument. | |
/// | |
/// This function is the only requirement of the `Comparable` protocol. The | |
/// remainder of the relational operator functions are implemented by the | |
/// standard library for any type that conforms to `Comparable`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func < (a: ScenePhase, b: ScenePhase) -> Bool | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension ScenePhase : Hashable { | |
} | |
/// A property wrapper type that reads and writes to persisted, per-scene | |
/// storage. | |
/// | |
/// You use `SceneStorage` when you need automatic state restoration of the | |
/// value. `SceneStorage` works very similar to `State`, except its initial | |
/// value is restored by the system if it was previously saved, and the value is· | |
/// shared with other `SceneStorage` variables in the same scene. | |
/// | |
/// The system manages the saving and restoring of `SceneStorage` on your | |
/// behalf. The underlying data that backs `SceneStorage` is not available to | |
/// you, so you must access it via the `SceneStorage` property wrapper. The | |
/// system makes no guarantees as to when and how often the data will be | |
/// persisted. | |
/// | |
/// Each `Scene` has its own notion of `SceneStorage`, so data is not shared | |
/// between scenes. | |
/// | |
/// Ensure that the data you use with `SceneStorage` is lightweight. Data of a | |
/// large size, such as model data, should not be stored in `SceneStorage`, as | |
/// poor performance may result. | |
/// | |
/// If the `Scene` is explicitly destroyed (e.g. the switcher snapshot is | |
/// destroyed on iPadOS or the window is closed on macOS), the data is also | |
/// destroyed. Do not use `SceneStorage` with sensitive data. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@frozen @propertyWrapper public struct SceneStorage<Value> : DynamicProperty { | |
/// The underlying value referenced by the state variable. | |
/// | |
/// This works identically to `State.wrappedValue`. | |
/// | |
/// - SeeAlso: State.wrappedValue | |
public var wrappedValue: Value { get nonmutating set } | |
/// A binding to the state value. | |
/// | |
/// This works identically to `State.projectedValue`. | |
/// | |
/// - SeeAlso: State.projectedValue | |
public var projectedValue: Binding<Value> { get } | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneStorage { | |
/// Creates a property that can save and restore a boolean. | |
/// | |
/// - Parameter wrappedValue: The default value if a boolean is not | |
/// available for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value == Bool | |
/// Creates a property that can save and restore an integer. | |
/// | |
/// - Parameter wrappedValue: The default value if an integer is not | |
/// available for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value == Int | |
/// Creates a property that can save and restore a double. | |
/// | |
/// - Parameter wrappedValue: The default value if a double is not available | |
/// for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value == Double | |
/// Creates a property that can save and restore a string. | |
/// | |
/// - Parameter wrappedValue: The default value if a string is not available | |
/// for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value == String | |
/// Creates a property that can save and restore a URL. | |
/// | |
/// - Parameter wrappedValue: The default value if a URL is not available | |
/// for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value == URL | |
/// Creates a property that can save and restore data. | |
/// | |
/// Avoid storing large data blobs, such as image data, as it can negatively | |
/// affect performance of your app. | |
/// | |
/// - Parameter wrappedValue: The default value if data is not available | |
/// for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value == Data | |
/// Creates a property that can save and restore an integer, transforming it | |
/// to a `RawRepresentable` data type. | |
/// | |
/// A common usage is with enumerations: | |
/// | |
/// enum MyEnum: Int { | |
/// case a | |
/// case b | |
/// case c | |
/// } | |
/// struct MyView: View { | |
/// @SceneStorage("MyEnumValue") private var value = MyEnum.a | |
/// var body: some View { ... } | |
/// } | |
/// | |
/// - Parameter wrappedValue: The default value if an integer value is not | |
/// available for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value : RawRepresentable, Value.RawValue == Int | |
/// Creates a property that can save and restore a string, transforming it | |
/// to a `RawRepresentable` data type. | |
/// | |
/// A common usage is with enumerations: | |
/// | |
/// enum MyEnum: String { | |
/// case a | |
/// case b | |
/// case c | |
/// } | |
/// struct MyView: View { | |
/// @SceneStorage("MyEnumValue") private var value = MyEnum.a | |
/// var body: some View { ... } | |
/// } | |
/// | |
/// - Parameter wrappedValue: The default value if a String value is not | |
/// available for the given key. | |
/// - Parameter key: a key used to save and restore the value. | |
public init(wrappedValue: Value, _ key: String) where Value : RawRepresentable, Value.RawValue == String | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension SceneStorage where Value : ExpressibleByNilLiteral { | |
/// Creates a property that can save and restore an Optional boolean. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init(_ key: String) where Value == Bool? | |
/// Creates a property that can save and restore an Optional integer. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init(_ key: String) where Value == Int? | |
/// Creates a property that can save and restore an Optional double. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init(_ key: String) where Value == Double? | |
/// Creates a property that can save and restore an Optional string. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init(_ key: String) where Value == String? | |
/// Creates a property that can save and restore an Optional URL. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init(_ key: String) where Value == URL? | |
/// Creates a property that can save and restore an Optional data. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init(_ key: String) where Value == Data? | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension SceneStorage { | |
/// Creates a property that can save and restore an Optional string, | |
/// transforming it to an Optional `RawRepresentable` data type. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// A common usage is with enumerations: | |
/// | |
/// enum MyEnum: String { | |
/// case a | |
/// case b | |
/// case c | |
/// } | |
/// struct MyView: View { | |
/// @SceneStorage("MyEnumValue") private var value: MyEnum? | |
/// var body: some View { ... } | |
/// } | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init<R>(_ key: String) where Value == R?, R : RawRepresentable, R.RawValue == String | |
/// Creates a property that can save and restore an Optional integer, | |
/// transforming it to an Optional `RawRepresentable` data type. | |
/// | |
/// Defaults to nil if there is no restored value | |
/// | |
/// A common usage is with enumerations: | |
/// | |
/// enum MyEnum: Int { | |
/// case a | |
/// case b | |
/// case c | |
/// } | |
/// struct MyView: View { | |
/// @SceneStorage("MyEnumValue") private var value: MyEnum? | |
/// var body: some View { ... } | |
/// } | |
/// | |
/// - Parameter key: a key used to save and restore the value. | |
public init<R>(_ key: String) where Value == R?, R : RawRepresentable, R.RawValue == Int | |
} | |
/// A scrollable view. | |
/// | |
/// The scroll view displays its content within the scrollable content region. | |
/// As the user performs platform-appropriate scroll gestures, the scroll view | |
/// adjusts what portion of the underlying content is visible. `ScrollView` can | |
/// scroll horizontally, vertically, or both, but does not provide zooming | |
/// functionality. | |
/// | |
/// In the following example, a `ScrollView` allows the user to scroll through | |
/// a ``VStack`` containing 100 ``Text`` views. The image after the listing | |
/// shows the scroll view's temporarily visible scrollbar at the right; you can | |
/// disable it with the `showsIndicators` parameter of the `ScrollView` | |
/// initializer. | |
/// | |
/// var body: some View { | |
/// ScrollView { | |
/// VStack(alignment: .leading) { | |
/// ForEach(0..<100) { | |
/// Text("Row \($0)") | |
/// } | |
/// } | |
/// } | |
/// } | |
/// ![A scroll view with a series of vertically arranged rows, reading | |
/// Row 1, Row 2, and so on. At the right, a scrollbar indicates that | |
/// this is the top of the scrollable | |
/// area.](SwiftUI-ScrollView-rows-with-indicator.png) | |
/// | |
/// To perform programmatic scrolling, wrap one or more scroll views with a | |
/// ``ScrollViewReader``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct ScrollView<Content> : View where Content : View { | |
/// The scroll view's content. | |
public var content: Content | |
/// The scrollable axes of the scroll view. | |
/// | |
/// The default value is ``Axis/vertical``. | |
public var axes: Axis.Set | |
/// A value that indicates whether the scroll view displays the scrollable | |
/// component of the content offset, in a way that's suitable for the | |
/// platform. | |
/// | |
/// The default is `true`. | |
public var showsIndicators: Bool | |
/// Creates a new instance that's scrollable in the direction of the given | |
/// axis and can show indicators while scrolling. | |
/// | |
/// - Parameters: | |
/// - axes: The scroll view's scrollable axis. The default axis is the | |
/// vertical axis. | |
/// - showsIndicators: A Boolean value that indicates whether the scroll | |
/// view displays the scrollable component of the content offset, in a way | |
/// suitable for the platform. The default value for this parameter is | |
/// `true`. | |
/// - content: The view builder that creates the scrollable view. | |
public init(_ axes: Axis.Set = .vertical, showsIndicators: Bool = true, @ViewBuilder content: () -> Content) | |
/// The content and behavior of the scroll view. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
/// A proxy value that supports programmatic scrolling of the scrollable | |
/// views within a view hierarchy. | |
/// | |
/// You don't create instances of `ScrollViewProxy` directly. Instead, your | |
/// ``ScrollViewReader`` receives an instance of `ScrollViewProxy` in its | |
/// `content` view builder. You use actions within this view builder, such | |
/// as button and gesture handlers or the ``View/onChange(of:perform:)`` | |
/// method, to call the proxy's ``ScrollViewProxy/scrollTo(_:anchor:)`` method. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public struct ScrollViewProxy { | |
/// Scans all scroll views contained by the proxy for the first | |
/// with a child view with identifier `id`, and then scrolls to | |
/// that view. | |
/// | |
/// If `anchor` is `nil`, this method finds the container of the identified | |
/// view, and scrolls the minimum amount to make the identified view | |
/// wholly visible. | |
/// | |
/// If `anchor` is non-`nil`, it defines the points in the identified | |
/// view and the scroll view to align. For example, setting `anchor` to | |
/// ``UnitPoint/top`` aligns the top of the identified view to the top of | |
/// the scroll view. Similarly, setting `anchor` to ``UnitPoint/bottom`` | |
/// aligns the bottom of the identified view to the bottom of the scroll | |
/// view, and so on. | |
/// | |
/// - Parameters: | |
/// - id: The identifier of a child view to scroll to. | |
/// - anchor: The alignment behavior of the scroll action. | |
public func scrollTo<ID>(_ id: ID, anchor: UnitPoint? = nil) where ID : Hashable | |
} | |
/// A view that provides programmatic scrolling, by working with a proxy | |
/// to scroll to known child views. | |
/// | |
/// The scroll view reader's content view builder receives a ``ScrollViewProxy`` | |
/// instance; you use the proxy's ``ScrollViewProxy/scrollTo(_:anchor:)`` to | |
/// perform scrolling. | |
/// | |
/// The following example creates a ``ScrollView`` containing 100 views that | |
/// together display a color gradient. It also contains two buttons, one each | |
/// at the top and bottom. The top button tells the ``ScrollViewProxy`` to | |
/// scroll to the bottom button, and vice versa. | |
/// | |
/// @Namespace var topID | |
/// @Namespace var bottomID | |
/// | |
/// var body: some View { | |
/// ScrollViewReader { proxy in | |
/// ScrollView { | |
/// Button("Scroll to Bottom") { | |
/// withAnimation { | |
/// proxy.scrollTo(bottomID) | |
/// } | |
/// } | |
/// .id(topID) | |
/// | |
/// VStack(spacing: 0) { | |
/// ForEach(0..<100) { i in | |
/// color(fraction: Double(i) / 100) | |
/// .frame(height: 32) | |
/// } | |
/// } | |
/// | |
/// Button("Top") { | |
/// withAnimation { | |
/// proxy.scrollTo(topID) | |
/// } | |
/// } | |
/// .id(bottomID) | |
/// } | |
/// } | |
/// } | |
/// | |
/// func color(fraction: Double) -> Color { | |
/// Color(red: fraction, green: 1 - fraction, blue: 0.5) | |
/// } | |
/// | |
/// ![A scroll view, with a button labeled "Scroll to Bottom" at top. | |
/// Below this, a series of vertically aligned rows, each filled with a | |
/// color, that are progressing from green to | |
/// red.](SwiftUI-ScrollViewReader-scroll-to-bottom-button.png) | |
/// | |
/// > Important: You may not use the ``ScrollViewProxy`` | |
/// during execution of the `content` view builder; doing so results in a | |
/// runtime error. Instead, only actions created within `content` can call | |
/// the proxy, such as gesture handlers or a view's `onChange(of:perform:)` | |
/// method. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@frozen public struct ScrollViewReader<Content> : View where Content : View { | |
/// The view builder that creates the reader's content. | |
public var content: (ScrollViewProxy) -> Content | |
/// Creates an instance that can perform programmatic scrolling of its | |
/// child scroll views. | |
/// | |
/// - Parameter content: The reader's content, containing one or more | |
/// scroll views. This view builder receives a ``ScrollViewProxy`` | |
/// instance that you use to perform scrolling. | |
@inlinable public init(@ViewBuilder content: @escaping (ScrollViewProxy) -> Content) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
/// A structure which defines the placement of a search field in a view | |
/// hierarchy. | |
/// | |
/// A preferred placement may be given to ``View/searchable(text:placement:)`` | |
/// modifier. | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// PrimaryView() | |
/// SecondaryView() | |
/// Text("Select a primary and secondary item") | |
/// } | |
/// .searchable(text: $text, placement: .sidebar) | |
/// } | |
/// | |
/// Depending on the containing view hierachy, the requested placement may | |
/// not be able to be fulfilled. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct SearchFieldPlacement { | |
/// The search field is placed automatically depending on the platform. | |
/// | |
/// On iOS, iPadOS, and macOS, the search field is placed in the toolbar. | |
/// | |
/// On tvOS and watchOS, the search field will be placed inline with its | |
/// content. | |
public static let automatic: SearchFieldPlacement | |
/// The search field is placed in the toolbar. | |
/// | |
/// On iOS and watchOS, the search field is placed beneath the | |
/// navigation bar and revealed by scrolling. | |
/// | |
/// On iPadOS, the search field is placed in the trailing | |
/// navigation bar. | |
/// | |
/// On macOS, the search field is placed in the trailing toolbar. | |
@available(tvOS, unavailable) | |
public static let toolbar: SearchFieldPlacement | |
/// The search field is placed in the sidebar of a navigation view. | |
/// | |
/// On iOS, and iPadOS the search field is placed in the section of | |
/// the navigation bar associated with the sidebar. | |
/// | |
/// On macOS, the search field is placed inline with the sidebar's content. | |
/// | |
/// If a sidebar is not available, the search field is placed inline with | |
/// other available content. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public static let sidebar: SearchFieldPlacement | |
/// The search field is placed in an drawer of the navigation bar. | |
/// | |
/// The drawer is beneath any navigation bar title, and depending | |
/// on the provided display mode, may collapse into the navigation bar as a | |
/// user scrolls the content. | |
@available(iOS 15.0, watchOS 8.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
public static let navigationBarDrawer: SearchFieldPlacement | |
/// The search field is placed in an drawer of the navigation bar. | |
/// | |
/// The drawer is beneath any navigation bar title, and collapses | |
/// into the navigation bar as a user scrolls the content depending on | |
/// the provided display mode. | |
/// | |
/// - Parameter displayMode: How to display the search field based on | |
/// the users content. | |
@available(iOS 15.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public static func navigationBarDrawer(displayMode: SearchFieldPlacement.NavigationBarDrawerDisplayMode) -> SearchFieldPlacement | |
} | |
extension SearchFieldPlacement { | |
/// A structure that defines the display behavior of a search field | |
/// when in the navigation bar drawer. | |
@available(iOS 15.0, *) | |
@available(macOS, unavailable) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct NavigationBarDrawerDisplayMode { | |
/// Allow the search field to be collapsed as the user scrolls | |
/// their content. | |
public static let automatic: SearchFieldPlacement.NavigationBarDrawerDisplayMode | |
/// Always display the search field no matter the scroll position of | |
/// the user's content. | |
public static let always: SearchFieldPlacement.NavigationBarDrawerDisplayMode | |
} | |
} | |
/// A container view that you can use to add hierarchy to certain collection views. | |
/// | |
/// Use `Section` instances in views like ``List``, ``Picker``, and | |
/// ``Form`` to organize content into separate sections. Each section has | |
/// custom content that you provide on a per-instance basis. You can also | |
/// provide headers and footers for each section. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct Section<Parent, Content, Footer> { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section : View where Parent : View, Content : View, Footer : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent : View, Content : View, Footer : View { | |
/// Creates a section with a header, footer, and the provided section | |
/// content. | |
/// | |
/// - Parameters: | |
/// - content: The section's content. | |
/// - header: A view to use as the section's header. | |
/// - footer: A view to use as the section's footer. | |
public init(@ViewBuilder content: () -> Content, @ViewBuilder header: () -> Parent, @ViewBuilder footer: () -> Footer) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent == EmptyView, Content : View, Footer : View { | |
/// Creates a section with a footer and the provided section content. | |
/// - Parameters: | |
/// - content: The section's content. | |
/// - footer: A view to use as the section's footer. | |
public init(@ViewBuilder content: () -> Content, @ViewBuilder footer: () -> Footer) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent : View, Content : View, Footer == EmptyView { | |
/// Creates a section with a header and the provided section content. | |
/// - Parameters: | |
/// - content: The section's content. | |
/// - header: A view to use as the section's header. | |
public init(@ViewBuilder content: () -> Content, @ViewBuilder header: () -> Parent) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent == EmptyView, Content : View, Footer == EmptyView { | |
/// Creates a section with the provided section content. | |
/// - Parameters: | |
/// - content: The section's content. | |
public init(@ViewBuilder content: () -> Content) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Section where Parent == Text, Content : View, Footer == EmptyView { | |
/// Creates a section with the provided section content. | |
/// - Parameters: | |
/// - titleKey: The key for the section's localized title, which describes | |
/// the contents of the section. | |
/// - content: The section's content. | |
public init(_ titleKey: LocalizedStringKey, @ViewBuilder content: () -> Content) | |
/// Creates a section with the provided section content. | |
/// - Parameters: | |
/// - title: A string that describes the contents of the section. | |
/// - content: The section's content. | |
public init<S>(_ title: S, @ViewBuilder content: () -> Content) where S : StringProtocol | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent : View, Content : View, Footer : View { | |
/// Creates a section with a header, footer, and the provided section content. | |
/// - Parameters: | |
/// - header: A view to use as the section's header. | |
/// - footer: A view to use as the section's footer. | |
/// - content: The section's content. | |
@available(iOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)") | |
@available(tvOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Section(content:header:footer:)") | |
public init(header: Parent, footer: Footer, @ViewBuilder content: () -> Content) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent == EmptyView, Content : View, Footer : View { | |
/// Creates a section with a footer and the provided section content. | |
/// - Parameters: | |
/// - footer: A view to use as the section's footer. | |
/// - content: The section's content. | |
@available(iOS, deprecated: 100000.0, renamed: "Section(content:footer:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Section(content:footer:)") | |
@available(tvOS, deprecated: 100000.0, renamed: "Section(content:footer:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Section(content:footer:)") | |
public init(footer: Footer, @ViewBuilder content: () -> Content) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Section where Parent : View, Content : View, Footer == EmptyView { | |
/// Creates a section with a header and the provided section content. | |
/// - Parameters: | |
/// - header: A view to use as the section's header. | |
/// - content: The section's content. | |
@available(iOS, deprecated: 100000.0, renamed: "Section(content:header:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Section(content:header:)") | |
@available(tvOS, deprecated: 100000.0, renamed: "Section(content:header:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Section(content:header:)") | |
public init(header: Parent, @ViewBuilder content: () -> Content) | |
} | |
/// A property wrapper type that makes sectioned fetch requests and retrieves the results | |
/// from a Core Data store. | |
/// | |
/// The fetch request and its results use the managed object context provided by | |
/// the environment value ``EnvironmentValues/managedObjectContext``. | |
/// The `sectionIdentifier` passed to the initializers is used to split the results into | |
/// sections. | |
/// | |
/// The sectioned fetch request's wrapped value works with ``ForEach`` to | |
/// drive collection views like ``List``: | |
/// | |
/// struct ContentView: View { | |
/// @SectionedFetchRequest<String, CoreDataPerson>( | |
/// sectionIdentifier: \.firstLetterOfName, | |
/// sortDescriptors: [NSSortDescriptor(keyPath: \Person.name, ascending: true)], | |
/// animation: .default | |
/// ) | |
/// private var sectionedPeople | |
/// | |
/// var body: some View { | |
/// List { | |
/// ForEach(sectionedPeople) { section in | |
/// Section(header: Text(section.id)) { | |
/// ForEach(section) { person in | |
/// Text(person.name) | |
/// } | |
/// } | |
/// } | |
/// } | |
/// } | |
/// } | |
/// | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
@propertyWrapper public struct SectionedFetchRequest<SectionIdentifier, Result> where SectionIdentifier : Hashable, Result : NSFetchRequestResult { | |
/// The results of the sectioned fetch request. | |
/// | |
/// This property returns an empty collection when there are no fetched results. | |
public var wrappedValue: SectionedFetchResults<SectionIdentifier, Result> { get } | |
/// The request's configurable properties. | |
public struct Configuration { | |
/// The request's section identifier keypath. | |
public var sectionIdentifier: KeyPath<Result, SectionIdentifier> | |
/// The request's sort descriptors. | |
public var nsSortDescriptors: [NSSortDescriptor] | |
/// The request's predicate. | |
public var nsPredicate: NSPredicate? | |
} | |
/// A binding to the request's mutable configuration properties | |
public var projectedValue: Binding<SectionedFetchRequest<SectionIdentifier, Result>.Configuration> { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension SectionedFetchRequest : DynamicProperty { | |
/// Updates the fetched results. | |
/// | |
/// SwiftUI calls this function before rendering a view's | |
/// ``View/body-swift.property`` to ensure the view has the most recent | |
/// fetched results. | |
public func update() | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension SectionedFetchRequest { | |
/// Creates an instance by defining a fetch request based on the parameters. | |
/// - Parameters: | |
/// - entity: The kind of modeled object to fetch. | |
/// - sectionIdentifier: Keypath on `Result` to a value that identifies | |
/// each object's section. | |
/// - sortDescriptors: An array of sort descriptors defines the sort | |
/// order of the fetched results. | |
/// - predicate: An NSPredicate defines a filter for the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(entity: NSEntityDescription, sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil) | |
/// Creates an instance from a fetch request. | |
/// - Parameters: | |
/// - fetchRequest: The request used to produce the fetched results. | |
/// - sectionIdentifier: Keypath on `Result` to a value that identifies | |
/// each object's section. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(fetchRequest: NSFetchRequest<Result>, sectionIdentifier: KeyPath<Result, SectionIdentifier>, animation: Animation? = nil) | |
/// Creates an instance from a fetch request. | |
/// - Parameters: | |
/// - fetchRequest: The request used to produce the fetched results. | |
/// - sectionIdentifier: Keypath on `Result` to a value that identifies | |
/// each object's section. | |
/// - transaction: The transaction used for any changes to the fetched | |
/// results. | |
public init(fetchRequest: NSFetchRequest<Result>, sectionIdentifier: KeyPath<Result, SectionIdentifier>, transaction: Transaction) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension SectionedFetchRequest where Result : NSManagedObject { | |
/// Creates an instance by defining a fetch request based on the parameters. | |
/// The fetch request will automatically infer the entity using Result.entity() at fetch-time. | |
/// - Parameters: | |
/// - sectionIdentifier: Keypath on `Result` to a value that identifies | |
/// each object's section. | |
/// - sortDescriptors: An array of sort descriptors defines the sort | |
/// order of the fetched results. | |
/// - predicate: An NSPredicate defines a filter for the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [NSSortDescriptor], predicate: NSPredicate? = nil, animation: Animation? = nil) | |
/// Creates an instance by defining a fetch request based on the parameters. | |
/// | |
/// The fetch request will automatically infer the entity using Result.entity() at fetch-time. | |
/// - Parameters: | |
/// - sectionIdentifier: Keypath on `Result` to a value that identifies | |
/// each object's section. | |
/// - sortDescriptors: An array of sort descriptors defines the sort | |
/// order of the fetched results. | |
/// - predicate: An NSPredicate defines a filter for the fetched results. | |
/// - animation: The animation used for any changes to the fetched | |
/// results. | |
public init(sectionIdentifier: KeyPath<Result, SectionIdentifier>, sortDescriptors: [SortDescriptor<Result>], predicate: NSPredicate? = nil, animation: Animation? = nil) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension SectionedFetchRequest.Configuration where Result : NSManagedObject { | |
public var sortDescriptors: [SortDescriptor<Result>] | |
} | |
/// The results of a sectioned fetch request, allowing for dynamic configuration | |
/// of the request. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct SectionedFetchResults<SectionIdentifier, Result> : RandomAccessCollection where SectionIdentifier : Hashable, Result : NSFetchRequestResult { | |
/// A section in a sectioned fetch request is a collection of results, plus the section's identifier. | |
public struct Section : Identifiable, RandomAccessCollection { | |
/// The position of the first element in a nonempty collection. | |
/// | |
/// If the collection is empty, `startIndex` is equal to `endIndex`. | |
public var startIndex: Int { get } | |
/// The collection's "past the end" position---that is, the position one | |
/// greater than the last valid subscript argument. | |
/// | |
/// When you need a range that includes the last element of a collection, use | |
/// the half-open range operator (`..<`) with `endIndex`. The `..<` operator | |
/// creates a range that doesn't include the upper bound, so it's always | |
/// safe to use with `endIndex`. For example: | |
/// | |
/// let numbers = [10, 20, 30, 40, 50] | |
/// if let index = numbers.firstIndex(of: 30) { | |
/// print(numbers[index ..< numbers.endIndex]) | |
/// } | |
/// // Prints "[30, 40, 50]" | |
/// | |
/// If the collection is empty, `endIndex` is equal to `startIndex`. | |
public var endIndex: Int { get } | |
/// Accesses the element at the specified position. | |
/// | |
/// The following example accesses an element of an array through its | |
/// subscript to print its value: | |
/// | |
/// var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] | |
/// print(streets[1]) | |
/// // Prints "Bryant" | |
/// | |
/// You can subscript a collection with any valid index other than the | |
/// collection's end index. The end index refers to the position one past | |
/// the last element of a collection, so it doesn't correspond with an | |
/// element. | |
/// | |
/// - Parameter position: The position of the element to access. `position` | |
/// must be a valid index of the collection that is not equal to the | |
/// `endIndex` property. | |
/// | |
/// - Complexity: O(1) | |
public subscript(position: Int) -> Result { get } | |
/// The value identifying the section | |
public let id: SectionIdentifier | |
/// A type representing the sequence's elements. | |
public typealias Element = Result | |
/// A type representing the stable identity of the entity associated with | |
/// an instance. | |
public typealias ID = SectionIdentifier | |
/// A type that represents a position in the collection. | |
/// | |
/// Valid indices consist of the position of every element and a | |
/// "past the end" position that's not valid for use as a subscript | |
/// argument. | |
public typealias Index = Int | |
/// A type that represents the indices that are valid for subscripting the | |
/// collection, in ascending order. | |
public typealias Indices = Range<Int> | |
/// A type that provides the collection's iteration interface and | |
/// encapsulates its iteration state. | |
/// | |
/// By default, a collection conforms to the `Sequence` protocol by | |
/// supplying `IndexingIterator` as its associated `Iterator` | |
/// type. | |
public typealias Iterator = IndexingIterator<SectionedFetchResults<SectionIdentifier, Result>.Section> | |
/// A sequence that represents a contiguous subrange of the collection's | |
/// elements. | |
/// | |
/// This associated type appears as a requirement in the `Sequence` | |
/// protocol, but it is restated here with stricter constraints. In a | |
/// collection, the subsequence should also conform to `Collection`. | |
public typealias SubSequence = Slice<SectionedFetchResults<SectionIdentifier, Result>.Section> | |
} | |
/// The request's sort descriptors. | |
public var nsSortDescriptors: [NSSortDescriptor] { get nonmutating set } | |
/// The request's predicate. | |
public var nsPredicate: NSPredicate? { get nonmutating set } | |
/// The request's section identifier keypath. | |
public var sectionIdentifier: KeyPath<Result, SectionIdentifier> { get nonmutating set } | |
/// The position of the first element in a nonempty collection. | |
/// | |
/// If the collection is empty, `startIndex` is equal to `endIndex`. | |
public var startIndex: Int { get } | |
/// The collection's "past the end" position---that is, the position one | |
/// greater than the last valid subscript argument. | |
/// | |
/// When you need a range that includes the last element of a collection, use | |
/// the half-open range operator (`..<`) with `endIndex`. The `..<` operator | |
/// creates a range that doesn't include the upper bound, so it's always | |
/// safe to use with `endIndex`. For example: | |
/// | |
/// let numbers = [10, 20, 30, 40, 50] | |
/// if let index = numbers.firstIndex(of: 30) { | |
/// print(numbers[index ..< numbers.endIndex]) | |
/// } | |
/// // Prints "[30, 40, 50]" | |
/// | |
/// If the collection is empty, `endIndex` is equal to `startIndex`. | |
public var endIndex: Int { get } | |
/// Accesses the element at the specified position. | |
/// | |
/// The following example accesses an element of an array through its | |
/// subscript to print its value: | |
/// | |
/// var streets = ["Adams", "Bryant", "Channing", "Douglas", "Evarts"] | |
/// print(streets[1]) | |
/// // Prints "Bryant" | |
/// | |
/// You can subscript a collection with any valid index other than the | |
/// collection's end index. The end index refers to the position one past | |
/// the last element of a collection, so it doesn't correspond with an | |
/// element. | |
/// | |
/// - Parameter position: The position of the element to access. `position` | |
/// must be a valid index of the collection that is not equal to the | |
/// `endIndex` property. | |
/// | |
/// - Complexity: O(1) | |
public subscript(position: Int) -> SectionedFetchResults<SectionIdentifier, Result>.Section { get } | |
/// A type representing the sequence's elements. | |
public typealias Element = SectionedFetchResults<SectionIdentifier, Result>.Section | |
/// A type that represents a position in the collection. | |
/// | |
/// Valid indices consist of the position of every element and a | |
/// "past the end" position that's not valid for use as a subscript | |
/// argument. | |
public typealias Index = Int | |
/// A type that represents the indices that are valid for subscripting the | |
/// collection, in ascending order. | |
public typealias Indices = Range<Int> | |
/// A type that provides the collection's iteration interface and | |
/// encapsulates its iteration state. | |
/// | |
/// By default, a collection conforms to the `Sequence` protocol by | |
/// supplying `IndexingIterator` as its associated `Iterator` | |
/// type. | |
public typealias Iterator = IndexingIterator<SectionedFetchResults<SectionIdentifier, Result>> | |
/// A sequence that represents a contiguous subrange of the collection's | |
/// elements. | |
/// | |
/// This associated type appears as a requirement in the `Sequence` | |
/// protocol, but it is restated here with stricter constraints. In a | |
/// collection, the subsequence should also conform to `Collection`. | |
public typealias SubSequence = Slice<SectionedFetchResults<SectionIdentifier, Result>> | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension SectionedFetchResults where Result : NSManagedObject { | |
public var sortDescriptors: [SortDescriptor<Result>] { get nonmutating set } | |
} | |
/// A control into which the user securely enters private text. | |
/// | |
/// Use a `SecureField` when you want behavior similar to a ``TextField``, but | |
/// you don't want the user's text to be visible. Typically, you use this for | |
/// entering passwords and other sensitive information. | |
/// | |
/// A `SecureField` uses a binding to a string value, and a closure that | |
/// executes when the user commits their edits, such as by pressing the | |
/// Return key. The field updates the bound string on every keystroke or | |
/// other edit, so you can read its value at any time from another control, | |
/// such as a Done button. | |
/// | |
/// The following example shows a `SecureField` bound to the string `password`. | |
/// If the user commits their edit in the secure field, the `onCommit` closure | |
/// sends the password string to a `handleLogin()` method. | |
/// | |
/// @State private var username: String = "" | |
/// @State private var password: String = "" | |
/// | |
/// var body: some View { | |
/// TextField( | |
/// "User name (email address)", | |
/// text: $username) | |
/// .autocapitalization(.none) | |
/// .disableAutocorrection(true) | |
/// .border(Color(UIColor.separator)) | |
/// SecureField( | |
/// "Password", | |
/// text: $password | |
/// ) { | |
/// handleLogin(username: username, password: password) | |
/// } | |
/// .border(Color(UIColor.separator)) | |
/// } | |
/// | |
/// ![Two vertically arranged views, the first a text field that displays the | |
/// email address mruiz2@icloud.com, the second view uses bullets in place of | |
/// the characters entered by the user for their password | |
/// password.](SwiftUI-SecureField-withTextField.png) | |
/// | |
/// ### SecureField Prompts | |
/// | |
/// A secure field may be provided an explicit prompt to guide users on what | |
/// text they should provide. The context in which a secure field appears | |
/// determines where and when a prompt and label may be used. For example, a | |
/// form on macOS will always place the label alongside the leading edge of | |
/// the field and will use a prompt, when available, as placeholder text within | |
/// the field itself. In the same context on iOS, the prompt or label will | |
/// be used as placeholder text depending on whether a prompt is provided. | |
/// | |
/// Form { | |
/// TextField(text: $username, prompt: Text("Required")) { | |
/// Text("Username") | |
/// } | |
/// SecureField(text: $username, prompt: Text("Required")) { | |
/// Text("Password") | |
/// } | |
/// } | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct SecureField<Label> : View where Label : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
extension SecureField where Label == Text { | |
/// Creates a secure field with a prompt generated from a `Text`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// secure field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title of `self`, describing | |
/// its purpose. | |
/// - text: The text to display and edit | |
/// - prompt: A `Text` representing the prompt of the secure field | |
/// which provides users with guidance on what to type into the secure | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, prompt: Text? = nil) | |
/// Creates a secure field with a prompt generated from a `Text`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// secure field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - title: The title of `self`, describing its purpose. | |
/// - text: The text to display and edit. | |
/// - prompt: A `Text` representing the prompt of the secure field | |
/// which provides users with guidance on what to type into the secure | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<S>(_ title: S, text: Binding<String>, prompt: Text? = nil) where S : StringProtocol | |
} | |
extension SecureField { | |
/// Creates a secure field with a prompt generated from a `Text`. | |
/// | |
/// - Parameters: | |
/// - text: The text to display and edit. | |
/// - prompt: A `Text` representing the prompt of the secure field | |
/// which provides users with guidance on what to type into the secure | |
/// field. | |
/// - label: A view that describes the purpose of the secure field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init(text: Binding<String>, prompt: Text? = nil, @ViewBuilder label: () -> Label) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension SecureField where Label == Text { | |
/// Creates an instance. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title of `self`, describing | |
/// its purpose. | |
/// - text: The text to display and edit. | |
/// - onCommit: The action to perform when the user performs an action | |
/// (usually pressing the Return key) while the secure field has focus. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, onCommit: @escaping () -> Void = {}) | |
/// Creates an instance. | |
/// | |
/// - Parameters: | |
/// - title: The title of `self`, describing its purpose. | |
/// - text: The text to display and edit. | |
/// - onCommit: The action to perform when the user performs an action | |
/// (usually pressing the Return key) while the secure field has focus. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed SecureField.init(_:text:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter.") | |
public init<S>(_ title: S, text: Binding<String>, onCommit: @escaping () -> Void = {}) where S : StringProtocol | |
} | |
/// A picker style that presents the options in a segmented control. | |
/// | |
/// Do not use this type directly. Instead, use ``PickerStyle/segmented``. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *) | |
@available(watchOS, unavailable) | |
public struct SegmentedPickerStyle : PickerStyle { | |
/// Creates a segmented picker style. | |
public init() | |
} | |
/// A style used to visually indicate selection following platform conventional | |
/// colors and behaviors. | |
/// | |
/// Do not use this type directly. Instead, use ``ShapeStyle/selection``. | |
@available(iOS 15.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct SelectionShapeStyle : ShapeStyle { | |
/// Creates a selection shape style. | |
@available(iOS, introduced: 15.0, deprecated: 15.0, message: "Use `.selection` instead.") | |
@available(macOS, introduced: 12.0, deprecated: 12.0, message: "Use `.selection` instead.") | |
public init() | |
} | |
/// A gesture that's a sequence of two gestures. | |
/// | |
/// Read <doc:Composing-SwiftUI-Gestures> to learn how you can create a sequence | |
/// of two gestures. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct SequenceGesture<First, Second> : Gesture where First : Gesture, Second : Gesture { | |
/// The value of a sequence gesture that helps to detect whether the first | |
/// gesture succeeded, so the second gesture can start. | |
@frozen public enum Value { | |
/// The first gesture hasn't ended. | |
case first(First.Value) | |
/// The first gesture has ended. | |
case second(First.Value, Second.Value?) | |
} | |
/// The first gesture in a sequence of two gestures. | |
public var first: First | |
/// The second gesture in a sequence of two gestures. | |
public var second: Second | |
/// Creates a sequence gesture with two gestures. | |
/// | |
/// - Parameters: | |
/// - first: The first gesture of the sequence. | |
/// - second: The second gesture of the sequence. | |
@inlinable public init(_ first: First, _ second: Second) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension SequenceGesture.Value : Equatable where First.Value : Equatable, Second.Value : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: SequenceGesture<First, Second>.Value, b: SequenceGesture<First, Second>.Value) -> Bool | |
} | |
/// A 2D shape that you can use when drawing a view. | |
/// | |
/// Shapes without an explicit fill or stroke get a default fill based on the | |
/// foreground color. | |
/// | |
/// You can define shapes in relation to an implicit frame of reference, such as | |
/// the natural size of the view that contains it. Alternatively, you can define | |
/// shapes in terms of absolute coordinates. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol Shape : Animatable, View { | |
/// Describes this shape as a path within a rectangular frame of reference. | |
/// | |
/// - Parameter rect: The frame of reference for describing this shape. | |
/// | |
/// - Returns: A path that describes this shape. | |
func path(in rect: CGRect) -> Path | |
/// An indication of how to style a shape. | |
/// | |
/// SwiftUI looks at a shape's role when deciding how to apply a | |
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a | |
/// default implementation with a value of ``ShapeRole/fill``. If you | |
/// create a composite shape, you can provide an override of this property | |
/// to return another value, if appropriate. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
static var role: ShapeRole { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Shape { | |
/// Trims this shape by a fractional amount based on its representation as a | |
/// path. | |
/// | |
/// To create a `Shape` instance, you define the shape's path using lines and | |
/// curves. Use the `trim(from:to:)` method to draw a portion of a shape by | |
/// ignoring portions of the beginning and ending of the shape's path. | |
/// | |
/// For example, if you're drawing a figure eight or infinity symbol (∞) | |
/// starting from its center, setting the `startFraction` and `endFraction` | |
/// to different values determines the parts of the overall shape. | |
/// | |
/// The following example shows a simplified infinity symbol that draws | |
/// only three quarters of the full shape. That is, of the two lobes of the | |
/// symbol, one lobe is complete and the other is half complete. | |
/// | |
/// Path { path in | |
/// path.addLines([ | |
/// .init(x: 2, y: 1), | |
/// .init(x: 1, y: 0), | |
/// .init(x: 0, y: 1), | |
/// .init(x: 1, y: 2), | |
/// .init(x: 3, y: 0), | |
/// .init(x: 4, y: 1), | |
/// .init(x: 3, y: 2), | |
/// .init(x: 2, y: 1) | |
/// ]) | |
/// } | |
/// .trim(from: 0.25, to: 1.0) | |
/// .scale(50, anchor: .topLeading) | |
/// .stroke(Color.black, lineWidth: 3) | |
/// | |
/// Changing the parameters of `trim(from:to:)` to | |
/// `.trim(from: 0, to: 1)` draws the full infinity symbol, while | |
/// `.trim(from: 0, to: 0.5)` draws only the left lobe of the symbol. | |
/// | |
/// - Parameters: | |
/// - startFraction: The fraction of the way through drawing this shape | |
/// where drawing starts. | |
/// - endFraction: The fraction of the way through drawing this shape | |
/// where drawing ends. | |
/// - Returns: A shape built by capturing a portion of this shape's path. | |
@inlinable public func trim(from startFraction: CGFloat = 0, to endFraction: CGFloat = 1) -> some Shape | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Shape { | |
/// Changes the relative position of this shape using the specified size. | |
/// | |
/// The following example renders two circles. It places one circle at its | |
/// default position. The second circle is outlined with a stroke, | |
/// positioned on top of the first circle and offset by 100 points to the | |
/// left and 50 points below. | |
/// | |
/// Circle() | |
/// .overlay( | |
/// Circle() | |
/// .offset(CGSize(width: -100, height: 50)) | |
/// .stroke() | |
/// ) | |
/// | |
/// - Parameter offset: The amount, in points, by which you offset the | |
/// shape. Negative numbers are to the left and up; positive numbers are | |
/// to the right and down. | |
/// | |
/// - Returns: A shape offset by the specified amount. | |
@inlinable public func offset(_ offset: CGSize) -> OffsetShape<Self> | |
/// Changes the relative position of this shape using the specified point. | |
/// | |
/// The following example renders two circles. It places one circle at its | |
/// default position. The second circle is outlined with a stroke, | |
/// positioned on top of the first circle and offset by 100 points to the | |
/// left and 50 points below. | |
/// | |
/// Circle() | |
/// .overlay( | |
/// Circle() | |
/// .offset(CGPoint(x: -100, y: 50)) | |
/// .stroke() | |
/// ) | |
/// | |
/// - Parameter offset: The amount, in points, by which you offset the | |
/// shape. Negative numbers are to the left and up; positive numbers are | |
/// to the right and down. | |
/// | |
/// - Returns: A shape offset by the specified amount. | |
@inlinable public func offset(_ offset: CGPoint) -> OffsetShape<Self> | |
/// Changes the relative position of this shape using the specified point. | |
/// | |
/// The following example renders two circles. It places one circle at its | |
/// default position. The second circle is outlined with a stroke, | |
/// positioned on top of the first circle and offset by 100 points to the | |
/// left and 50 points below. | |
/// | |
/// Circle() | |
/// .overlay( | |
/// Circle() | |
/// .offset(x: -100, y: 50) | |
/// .stroke() | |
/// ) | |
/// | |
/// - Parameters: | |
/// - x: The horizontal amount, in points, by which you offset the shape. | |
/// Negative numbers are to the left and positive numbers are to the | |
/// right. | |
/// - y: The vertical amount, in points, by which you offset the shape. | |
/// Negative numbers are up and positive numbers are down. | |
/// | |
/// - Returns: A shape offset by the specified amount. | |
@inlinable public func offset(x: CGFloat = 0, y: CGFloat = 0) -> OffsetShape<Self> | |
/// Scales this shape without changing its bounding frame. | |
/// | |
/// Both the `x` and `y` multiplication factors halve their respective | |
/// dimension's size when set to `0.5`, maintain their existing size when | |
/// set to `1`, double their size when set to `2`, and so forth. | |
/// | |
/// - Parameters: | |
/// - x: The multiplication factor used to resize this shape along its | |
/// x-axis. | |
/// - y: The multiplication factor used to resize this shape along its | |
/// y-axis. | |
/// | |
/// - Returns: A scaled form of this shape. | |
@inlinable public func scale(x: CGFloat = 1, y: CGFloat = 1, anchor: UnitPoint = .center) -> ScaledShape<Self> | |
/// Scales this shape without changing its bounding frame. | |
/// | |
/// - Parameter scale: The multiplication factor used to resize this shape. | |
/// A value of `0` scales the shape to have no size, `0.5` scales to half | |
/// size in both dimensions, `2` scales to twice the regular size, and so | |
/// on. | |
/// | |
/// - Returns: A scaled form of this shape. | |
@inlinable public func scale(_ scale: CGFloat, anchor: UnitPoint = .center) -> ScaledShape<Self> | |
/// Rotates this shape around an anchor point at the angle you specify. | |
/// | |
/// The following example rotates a square by 45 degrees to the right to | |
/// create a diamond shape: | |
/// | |
/// RoundedRectangle(cornerRadius: 10) | |
/// .rotation(Angle(degrees: 45)) | |
/// .aspectRatio(1.0, contentMode: .fit) | |
/// | |
/// - Parameters: | |
/// - angle: The angle of rotation to apply. Positive angles rotate | |
/// clockwise; negative angles rotate counterclockwise. | |
/// - anchor: The point to rotate the shape around. | |
/// | |
/// - Returns: A rotated shape. | |
@inlinable public func rotation(_ angle: Angle, anchor: UnitPoint = .center) -> RotatedShape<Self> | |
/// Applies an affine transform to this shape. | |
/// | |
/// Affine transforms present a mathematical approach to applying | |
/// combinations of rotation, scaling, translation, and skew to shapes. | |
/// | |
/// - Parameter transform: The affine transformation matrix to apply to this | |
/// shape. | |
/// | |
/// - Returns: A transformed shape, based on its matrix values. | |
@inlinable public func transform(_ transform: CGAffineTransform) -> TransformedShape<Self> | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Shape { | |
/// Returns a new version of self representing the same shape, but | |
/// that will ask it to create its path from a rect of `size`. This | |
/// does not affect the layout properties of any views created from | |
/// the shape (e.g. by filling it). | |
@inlinable public func size(_ size: CGSize) -> some Shape | |
/// Returns a new version of self representing the same shape, but | |
/// that will ask it to create its path from a rect of size | |
/// `(width, height)`. This does not affect the layout properties | |
/// of any views created from the shape (e.g. by filling it). | |
@inlinable public func size(width: CGFloat, height: CGFloat) -> some Shape | |
} | |
extension Shape { | |
/// An indication of how to style a shape. | |
/// | |
/// SwiftUI looks at a shape's role when deciding how to apply a | |
/// ``ShapeStyle`` at render time. The ``Shape`` protocol provides a | |
/// default implementation with a value of ``ShapeRole/fill``. If you | |
/// create a composite shape, you can provide an override of this property | |
/// to return another value, if appropriate. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var role: ShapeRole { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Shape { | |
/// Fills this shape with a color or gradient. | |
/// | |
/// - Parameters: | |
/// - content: The color or gradient to use when filling this shape. | |
/// - style: The style options that determine how the fill renders. | |
/// - Returns: A shape filled with the color or gradient you supply. | |
@inlinable public func fill<S>(_ content: S, style: FillStyle = FillStyle()) -> some View where S : ShapeStyle | |
/// Fills this shape with the foreground color. | |
/// | |
/// - Parameter style: The style options that determine how the fill | |
/// renders. | |
/// - Returns: A shape filled with the foreground color. | |
@inlinable public func fill(style: FillStyle = FillStyle()) -> some View | |
/// Traces the outline of this shape with a color or gradient. | |
/// | |
/// The following example adds a dashed purple stroke to a `Capsule`: | |
/// | |
/// Capsule() | |
/// .stroke( | |
/// Color.purple, | |
/// style: StrokeStyle( | |
/// lineWidth: 5, | |
/// lineCap: .round, | |
/// lineJoin: .miter, | |
/// miterLimit: 0, | |
/// dash: [5, 10], | |
/// dashPhase: 0 | |
/// ) | |
/// ) | |
/// | |
/// - Parameters: | |
/// - content: The color or gradient with which to stroke this shape. | |
/// - style: The stroke characteristics --- such as the line's width and | |
/// whether the stroke is dashed --- that determine how to render this | |
/// shape. | |
/// - Returns: A stroked shape. | |
@inlinable public func stroke<S>(_ content: S, style: StrokeStyle) -> some View where S : ShapeStyle | |
/// Traces the outline of this shape with a color or gradient. | |
/// | |
/// The following example draws a circle with a purple stroke: | |
/// | |
/// Circle().stroke(Color.purple, lineWidth: 5) | |
/// | |
/// - Parameters: | |
/// - content: The color or gradient with which to stroke this shape. | |
/// - lineWidth: The width of the stroke that outlines this shape. | |
/// - Returns: A stroked shape. | |
@inlinable public func stroke<S>(_ content: S, lineWidth: CGFloat = 1) -> some View where S : ShapeStyle | |
} | |
/// A shape acts as view by filling itself with the foreground color and | |
/// default fill style. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Shape { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: _ShapeView<Self, ForegroundStyle> { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Shape { | |
/// Returns a new shape that is a stroked copy of `self`, using the | |
/// contents of `style` to define the stroke characteristics. | |
@inlinable public func stroke(style: StrokeStyle) -> some Shape | |
/// Returns a new shape that is a stroked copy of `self` with | |
/// line-width defined by `lineWidth` and all other properties of | |
/// `StrokeStyle` having their default values. | |
@inlinable public func stroke(lineWidth: CGFloat = 1) -> some Shape | |
} | |
/// Ways of styling a shape. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public enum ShapeRole { | |
/// Indicates to the shape's style that SwiftUI fills the shape. | |
case fill | |
/// Indicates to the shape's style that SwiftUI applies a stroke to | |
/// the shape's path. | |
case stroke | |
/// Indicates to the shape's style that SwiftUI uses the shape as a | |
/// separator. | |
case separator | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: ShapeRole, b: ShapeRole) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeRole : Equatable { | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeRole : Hashable { | |
} | |
/// A color or pattern to use when rendering a shape. | |
/// | |
/// You don't use the `ShapeStyle` protocol directly. Instead, use one of | |
/// the concrete styles that SwiftUI defines. To indicate a specific color | |
/// or pattern, you can use ``Color`` or the style returned by | |
/// ``ShapeStyle/image(_:sourceRect:scale:)``, or one of the gradient | |
/// types, like the one returned by ``ShapeStyle/radial(_:center:startRadius:endRadius:)``. | |
/// To set a color that's appropriate for a given context on a given | |
/// platform, use one of the semantic styles, like ``ShapeStyle/background`` or | |
/// ``ShapeStyle/primary``. | |
/// | |
/// You can use a shape style by: | |
/// * Filling a shape with a style with the ``Shape/fill(_:style:)`` modifier: | |
/// | |
/// ``` | |
/// Path { path in | |
/// path.move(to: .zero) | |
/// path.addLine(to: CGPoint(x: 50, y: 0)) | |
/// path.addArc( | |
/// center: .zero, | |
/// radius: 50, | |
/// startAngle: .zero, | |
/// endAngle: .degrees(90), | |
/// clockwise: false) | |
/// } | |
/// .fill(.radial( | |
/// Gradient(colors: [.yellow, .red]), | |
/// center: .topLeading, | |
/// startRadius: 15, | |
/// endRadius: 80)) | |
/// ``` | |
/// | |
/// ![A screenshot of a quarter of a circle filled with | |
/// a radial gradient.](ShapeStyle-1) | |
/// | |
/// * Tracing the outline of a shape with a style with either the | |
/// ``Shape/stroke(_:lineWidth:)`` or the ``Shape/stroke(_:style:)`` modifier: | |
/// | |
/// ``` | |
/// RoundedRectangle(cornerRadius: 10) | |
/// .stroke(.mint, lineWidth: 10) | |
/// .frame(width: 200, height: 50) | |
/// ``` | |
/// | |
/// ![A screenshot of a rounded rectangle, outlined in mint.](ShapeStyle-2) | |
/// | |
/// * Styling the foreground elements in a view with the | |
/// ``View/foregroundStyle(_:)`` modifier: | |
/// | |
/// ``` | |
/// VStack(alignment: .leading) { | |
/// Text("Primary") | |
/// .font(.title) | |
/// Text("Secondary") | |
/// .font(.caption) | |
/// .foregroundStyle(.secondary) | |
/// } | |
/// ``` | |
/// | |
/// ![A screenshot of a title in the primary content color above a | |
/// subtitle in the secondary content color.](ShapeStyle-3) | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public protocol ShapeStyle { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self == ImagePaint { | |
/// A shape style that fills a shape by repeating a region of an image. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
/// | |
/// - Parameters: | |
/// - image: The image to be drawn. | |
/// - sourceRect: A unit-space rectangle defining how much of the source | |
/// image to draw. The results are undefined if `sourceRect` selects | |
/// areas outside the `[0, 1]` range in either axis. | |
/// - scale: A scale factor applied to the image during rendering. | |
public static func image(_ image: Image, sourceRect: CGRect = CGRect(x: 0, y: 0, width: 1, height: 1), scale: CGFloat = 1) -> ImagePaint | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle { | |
/// Maps a shape style's unit-space coordinates to the absolute coordinates | |
/// of a given rectangle. | |
/// | |
/// Some shape styles have colors or patterns that vary | |
/// with position based on ``UnitPoint`` coordinates. For example, you | |
/// can create a ``LinearGradient`` using ``UnitPoint/top`` and | |
/// ``UnitPoint/bottom`` as the start and end points: | |
/// | |
/// let gradient = LinearGradient( | |
/// colors: [.red, .yellow], | |
/// startPoint: .top, | |
/// endPoint: .bottom) | |
/// | |
/// When rendering such styles, SwiftUI maps the unit space coordinates to | |
/// the absolute coordinates of the filled shape. However, you can tell | |
/// SwiftUI to use a different set of coordinates by supplying a rectangle | |
/// to the `in(_:)` method. Consider two resizable rectangles using the | |
/// gradient defined above: | |
/// | |
/// HStack { | |
/// Rectangle() | |
/// .fill(gradient) | |
/// Rectangle() | |
/// .fill(gradient.in(CGRect(x: 0, y: 0, width: 0, height: 300))) | |
/// } | |
/// .onTapGesture { isBig.toggle() } | |
/// .frame(height: isBig ? 300 : 50) | |
/// .animation(.easeInOut) | |
/// | |
/// When `isBig` is true — defined elsewhere as a private ``State`` | |
/// variable — the rectangles look the same, because their heights | |
/// match that of the modified gradient: | |
/// | |
/// ![Two identical, tall rectangles, with a gradient that starts red at | |
/// the top and transitions to yellow at the bottom.](ShapeStyle-in-1) | |
/// | |
/// When the user toggles `isBig` by tapping the ``HStack``, the | |
/// rectangles shrink, but the gradients each react in a different way: | |
/// | |
/// ![Two short rectangles with different coloration. The first has a | |
/// gradient that transitions top to bottom from full red to full yellow. | |
/// The second starts as red at the top and then begins to transition | |
/// to yellow toward the bottom.](ShapeStyle-in-2) | |
/// | |
/// SwiftUI remaps the gradient of the first rectangle to the new frame | |
/// height, so that you continue to see the full range of colors in a | |
/// smaller area. For the second rectangle, the modified gradient retains | |
/// a mapping to the full height, so you instead see only a small part of | |
/// the overall gradient. Animation helps to visualize the difference. | |
/// | |
/// - Parameter rect: A rectangle that gives the absolute coordinates over | |
/// which to map the shape style. | |
/// - Returns: A new shape style mapped to the coordinates given by `rect`. | |
@inlinable public func `in`(_ rect: CGRect) -> some ShapeStyle | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeStyle where Self == HierarchicalShapeStyle { | |
/// A shape style that maps to the first level of the current content style. | |
/// | |
/// This hierarchical style maps to the first level of the current | |
/// foreground style, or to the first level of the default foreground style | |
/// if you haven't set a foreground style in the view's environment. You | |
/// typically set a foreground style by supplying a non-hierarchical style | |
/// to the ``View/foregroundStyle(_:)`` modifier. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var primary: HierarchicalShapeStyle { get } | |
/// A shape style that maps to the second level of the current content style. | |
/// | |
/// This hierarchical style maps to the second level of the current | |
/// foreground style, or to the second level of the default foreground style | |
/// if you haven't set a foreground style in the view's environment. You | |
/// typically set a foreground style by supplying a non-hierarchical style | |
/// to the ``View/foregroundStyle(_:)`` modifier. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var secondary: HierarchicalShapeStyle { get } | |
/// A shape style that maps to the third level of the current content | |
/// style. | |
/// | |
/// This hierarchical style maps to the third level of the current | |
/// foreground style, or to the third level of the default foreground style | |
/// if you haven't set a foreground style in the view's environment. You | |
/// typically set a foreground style by supplying a non-hierarchical style | |
/// to the ``View/foregroundStyle(_:)`` modifier. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var tertiary: HierarchicalShapeStyle { get } | |
/// A shape style that maps to the fourth level of the current content | |
/// style. | |
/// | |
/// This hierarchical style maps to the fourth level of the current | |
/// foreground style, or to the fourth level of the default foreground style | |
/// if you haven't set a foreground style in the view's environment. You | |
/// typically set a foreground style by supplying a non-hierarchical style | |
/// to the ``View/foregroundStyle(_:)`` modifier. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var quaternary: HierarchicalShapeStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self == Color { | |
/// A context-dependent red color suitable for use in UI elements. | |
public static var red: Color { get } | |
/// A context-dependent orange color suitable for use in UI elements. | |
public static var orange: Color { get } | |
/// A context-dependent yellow color suitable for use in UI elements. | |
public static var yellow: Color { get } | |
/// A context-dependent green color suitable for use in UI elements. | |
public static var green: Color { get } | |
/// A context-dependent mint color suitable for use in UI elements. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var mint: Color { get } | |
/// A context-dependent teal color suitable for use in UI elements. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var teal: Color { get } | |
/// A context-dependent cyan color suitable for use in UI elements. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var cyan: Color { get } | |
/// A context-dependent blue color suitable for use in UI elements. | |
public static var blue: Color { get } | |
/// A context-dependent indigo color suitable for use in UI elements. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var indigo: Color { get } | |
/// A context-dependent purple color suitable for use in UI elements. | |
public static var purple: Color { get } | |
/// A context-dependent pink color suitable for use in UI elements. | |
public static var pink: Color { get } | |
/// A context-dependent brown color suitable for use in UI elements. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public static var brown: Color { get } | |
/// A white color suitable for use in UI elements. | |
public static var white: Color { get } | |
/// A context-dependent gray color suitable for use in UI elements. | |
public static var gray: Color { get } | |
/// A black color suitable for use in UI elements. | |
public static var black: Color { get } | |
/// A clear color suitable for use in UI elements. | |
public static var clear: Color { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self == LinearGradient { | |
/// A linear gradient. | |
/// | |
/// The gradient applies the color function along an axis, as defined by its | |
/// start and end points. The gradient maps the unit space points into the | |
/// bounding rectangle of each shape filled with the gradient. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func linearGradient(_ gradient: Gradient, startPoint: UnitPoint, endPoint: UnitPoint) -> LinearGradient | |
/// A linear gradient defined by a collection of colors. | |
/// | |
/// The gradient applies the color function along an axis, as defined by its | |
/// start and end points. The gradient maps the unit space points into the | |
/// bounding rectangle of each shape filled with the gradient. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func linearGradient(colors: [Color], startPoint: UnitPoint, endPoint: UnitPoint) -> LinearGradient | |
/// A linear gradient defined by a collection of color stops. | |
/// | |
/// The gradient applies the color function along an axis, as defined by its | |
/// start and end points. The gradient maps the unit space points into the | |
/// bounding rectangle of each shape filled with the gradient. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func linearGradient(stops: [Gradient.Stop], startPoint: UnitPoint, endPoint: UnitPoint) -> LinearGradient | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self == RadialGradient { | |
/// A radial gradient. | |
/// | |
/// The gradient applies the color function as the distance from a center | |
/// point, scaled to fit within the defined start and end radii. The | |
/// gradient maps the unit space center point into the bounding rectangle of | |
/// each shape filled with the gradient. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func radialGradient(_ gradient: Gradient, center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) -> RadialGradient | |
/// A radial gradient defined by a collection of colors. | |
/// | |
/// The gradient applies the color function as the distance from a center | |
/// point, scaled to fit within the defined start and end radii. The | |
/// gradient maps the unit space center point into the bounding rectangle of | |
/// each shape filled with the gradient. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func radialGradient(colors: [Color], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) -> RadialGradient | |
/// A radial gradient defined by a collection of color stops. | |
/// | |
/// The gradient applies the color function as the distance from a center | |
/// point, scaled to fit within the defined start and end radii. The | |
/// gradient maps the unit space center point into the bounding rectangle of | |
/// each shape filled with the gradient. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func radialGradient(stops: [Gradient.Stop], center: UnitPoint, startRadius: CGFloat, endRadius: CGFloat) -> RadialGradient | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeStyle where Self == EllipticalGradient { | |
/// A radial gradient that draws an ellipse. | |
/// | |
/// The gradient maps its coordinate space to the unit space square | |
/// in which its center and radii are defined, then stretches that | |
/// square to fill its bounding rect, possibly also stretching the | |
/// circular gradient to have elliptical contours. | |
/// | |
/// For example, an elliptical gradient used as a background: | |
/// | |
/// let gradient = Gradient(colors: [.red, .yellow]) | |
/// | |
/// ContentView() | |
/// .background(.ellipticalGradient(gradient)) | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func ellipticalGradient(_ gradient: Gradient, center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> EllipticalGradient | |
/// A radial gradient that draws an ellipse defined by a collection of | |
/// colors. | |
/// | |
/// The gradient maps its coordinate space to the unit space square | |
/// in which its center and radii are defined, then stretches that | |
/// square to fill its bounding rect, possibly also stretching the | |
/// circular gradient to have elliptical contours. | |
/// | |
/// For example, an elliptical gradient used as a background: | |
/// | |
/// .background(.elliptical(colors: [.red, .yellow])) | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func ellipticalGradient(colors: [Color], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> EllipticalGradient | |
/// A radial gradient that draws an ellipse defined by a collection of | |
/// color stops. | |
/// | |
/// The gradient maps its coordinate space to the unit space square | |
/// in which its center and radii are defined, then stretches that | |
/// square to fill its bounding rect, possibly also stretching the | |
/// circular gradient to have elliptical contours. | |
/// | |
/// For example, an elliptical gradient used as a background: | |
/// | |
/// .background(.ellipticalGradient(stops: [ | |
/// .init(color: .red, location: 0.0), | |
/// .init(color: .yellow, location: 0.9), | |
/// .init(color: .yellow, location: 1.0), | |
/// ])) | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static func ellipticalGradient(stops: [Gradient.Stop], center: UnitPoint = .center, startRadiusFraction: CGFloat = 0, endRadiusFraction: CGFloat = 0.5) -> EllipticalGradient | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self == AngularGradient { | |
/// An angular gradient, which applies the color function as the angle | |
/// changes between the start and end angles, and anchored to a relative | |
/// center point within the filled shape. | |
/// | |
/// An angular gradient is also known as a "conic" gradient. If | |
/// `endAngle - startAngle > 2π`, the gradient only draws the last complete | |
/// turn. If `endAngle - startAngle < 2π`, the gradient fills the missing | |
/// area with the colors defined by gradient stop locations at `0` and `1`, | |
/// transitioning between the two halfway across the missing area. | |
/// | |
/// For example, an angular gradient used as a background: | |
/// | |
/// let gradient = Gradient(colors: [.red, .yellow]) | |
/// | |
/// ContentView() | |
/// .background(.angularGradient(gradient)) | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
/// | |
/// - Parameters: | |
/// - gradient: The gradient to use for filling the shape, providing the | |
/// colors and their relative stop locations. | |
/// - center: The relative center of the gradient, mapped from the unit | |
/// space into the bounding rectangle of the filled shape. | |
/// - startAngle: The angle that marks the beginning of the gradient. | |
/// - endAngle: The angle that marks the end of the gradient. | |
public static func angularGradient(_ gradient: Gradient, center: UnitPoint, startAngle: Angle, endAngle: Angle) -> AngularGradient | |
/// An angular gradient defined by a collection of colors. | |
/// | |
/// For more information on how to use angular gradients, see | |
/// ``ShapeStyle/angularGradient(_:center:startAngle:endAngle:)``. | |
/// | |
/// - Parameters: | |
/// - colors: The colors of the gradient, evenly spaced along its full | |
/// length. | |
/// - center: The relative center of the gradient, mapped from the unit | |
/// space into the bounding rectangle of the filled shape. | |
/// - startAngle: The angle that marks the beginning of the gradient. | |
/// - endAngle: The angle that marks the end of the gradient. | |
public static func angularGradient(colors: [Color], center: UnitPoint, startAngle: Angle, endAngle: Angle) -> AngularGradient | |
/// An angular gradient defined by a collection of color stops. | |
/// | |
/// For more information on how to use angular gradients, see | |
/// ``ShapeStyle/angularGradient(_:center:startAngle:endAngle:)``. | |
/// | |
/// - Parameters: | |
/// - stops: The color stops of the gradient, defining each component | |
/// color and their relative location along the gradient's full length. | |
/// - center: The relative center of the gradient, mapped from the unit | |
/// space into the bounding rectangle of the filled shape. | |
/// - startAngle: The angle that marks the beginning of the gradient. | |
/// - endAngle: The angle that marks the end of the gradient. | |
public static func angularGradient(stops: [Gradient.Stop], center: UnitPoint, startAngle: Angle, endAngle: Angle) -> AngularGradient | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self == AngularGradient { | |
/// A conic gradient that completes a full turn, optionally starting from | |
/// a given angle and anchored to a relative center point within the filled | |
/// shape. | |
/// | |
/// For example, a conic gradient used as a background: | |
/// | |
/// let gradient = Gradient(colors: [.red, .yellow]) | |
/// | |
/// ContentView() | |
/// .background(.conicGradient(gradient)) | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
/// | |
/// - Parameters: | |
/// - gradient: The gradient to use for filling the shape, providing the | |
/// colors and their relative stop locations. | |
/// - center: The relative center of the gradient, mapped from the unit | |
/// space into the bounding rectangle of the filled shape. | |
/// - angle: The angle to offset the beginning of the gradient's full | |
/// turn. | |
public static func conicGradient(_ gradient: Gradient, center: UnitPoint, angle: Angle = .zero) -> AngularGradient | |
/// A conic gradient defined by a collection of colors that completes a full | |
/// turn. | |
/// | |
/// For more information on how to use angular gradients, see | |
/// ``ShapeStyle/conicGradient(_:center:angle:)``. | |
/// | |
/// - Parameters: | |
/// - colors: The colors of the gradient, evenly spaced along its full | |
/// length. | |
/// - center: The relative center of the gradient, mapped from the unit | |
/// space into the bounding rectangle of the filled shape. | |
/// - angle: The angle to offset the beginning of the gradient's full | |
/// turn. | |
public static func conicGradient(colors: [Color], center: UnitPoint, angle: Angle = .zero) -> AngularGradient | |
/// A conic gradient defined by a collection of color stops that completes a | |
/// full turn. | |
/// | |
/// For more information on how to use angular gradients, see | |
/// ``ShapeStyle/conicGradient(_:center:angle:)``. | |
/// | |
/// - Parameters: | |
/// - stops: The color stops of the gradient, defining each component | |
/// color and their relative location along the gradient's full length. | |
/// - center: The relative center of the gradient, mapped from the unit | |
/// space into the bounding rectangle of the filled shape. | |
/// - angle: The angle to offset the beginning of the gradient's full | |
/// turn. | |
public static func conicGradient(stops: [Gradient.Stop], center: UnitPoint, angle: Angle = .zero) -> AngularGradient | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeStyle where Self == BackgroundStyle { | |
/// The background style in the current context. | |
/// | |
/// Access this value to get the style SwiftUI uses for the background | |
/// in the current context. The specific color that SwiftUI renders depends | |
/// on factors like the platform and whether the user has turned on Dark | |
/// Mode. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var background: BackgroundStyle { get } | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ShapeStyle where Self == SelectionShapeStyle { | |
/// A style used to visually indicate selection following platform conventional | |
/// colors and behaviors. | |
/// | |
/// For example: | |
/// | |
/// ForEach(items) { | |
/// ItemView(value: item, isSelected: item.id == selectedID) | |
/// } | |
/// | |
/// struct ItemView { | |
/// var value: item | |
/// var isSelected: Bool | |
/// | |
/// var body: some View { | |
/// // construct the actual cell content | |
/// .background(selectionBackground) | |
/// } | |
/// @ViewBuilder | |
/// private var selectionBackground: some View { | |
/// if isSelected { | |
/// RoundedRectangle(cornerRadius: 8) | |
/// .fill(.selection) | |
/// } | |
/// } | |
/// } | |
/// | |
/// On macOS and iPadOS this automatically reflects window key state and focus | |
/// state, where the emphasized appearance will be used only when the window is | |
/// key and the nearest focusable element is actually focused. On iPhone, this | |
/// will always fill with the environment's accent color. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var selection: SelectionShapeStyle { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension ShapeStyle where Self : View, Self.Body == _ShapeView<Rectangle, Self> { | |
/// A rectangular view that's filled with the shape style. | |
/// | |
/// For a ``ShapeStyle`` that also conforms to the ``View`` protocol, like | |
/// ``Color`` or ``LinearGradient``, this default implementation of the | |
/// ``View/body-swift.property`` property provides a visual representation | |
/// for the shape style. As a result, you can use the shape style in a view | |
/// hierarchy like any other view: | |
/// | |
/// ZStack { | |
/// Color.cyan | |
/// Text("Hello!") | |
/// } | |
/// .frame(width: 200, height: 50) | |
/// | |
/// ![A screenshot of a cyan rectangle with the text hello appearing | |
/// in the middle of the rectangle.](ShapeStyle-body-1) | |
public var body: _ShapeView<Rectangle, Self> { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, *) | |
@available(watchOS, unavailable) | |
extension ShapeStyle where Self == Material { | |
/// A material that's somewhat translucent. | |
public static var regularMaterial: Material { get } | |
/// A material that's more opaque than translucent. | |
public static var thickMaterial: Material { get } | |
/// A material that's more translucent than opaque. | |
public static var thinMaterial: Material { get } | |
/// A mostly translucent material. | |
public static var ultraThinMaterial: Material { get } | |
/// A mostly opaque material. | |
public static var ultraThickMaterial: Material { get } | |
} | |
@available(iOS 15.0, macOS 12.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension ShapeStyle where Self == Material { | |
/// A material matching the style of system toolbars. | |
public static var bar: Material { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeStyle where Self == ForegroundStyle { | |
/// The foreground style in the current context. | |
/// | |
/// Access this value to get the style SwiftUI uses for foreground elements, | |
/// like text, symbols, and shapes, in the current context. Use the | |
/// ``View/foregroundStyle(_:)`` modifier to set a new foreground style for | |
/// a given view and its child views. | |
/// | |
/// For information about how to use shape styles, see ``ShapeStyle``. | |
public static var foreground: ForegroundStyle { get } | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension ShapeStyle where Self == TintShapeStyle { | |
/// A style that reflects the current tint color. | |
/// | |
/// You can set the tint color with the `tint(_:)` modifier. If no explicit | |
/// tint is set, the tint is derived from the app's accent color. | |
public static var tint: TintShapeStyle { get } | |
} | |
/// A built-in set of commands for manipulating window sidebars. | |
/// | |
/// These commands are optional and can be explicitly requested by passing a | |
/// value of this type to the `Scene/commands(content:)`` modifier. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct SidebarCommands : Commands { | |
/// A new value describing the built-in sidebar-related commands. | |
public init() | |
/// The contents of the command hierarchy. | |
/// | |
/// For any commands that you create, provide a computed `body` property | |
/// that defines the scene as a composition of other scenes. You can | |
/// assemble a command hierarchy from primitive commands that SwiftUI | |
/// provides, as well as other commands that you've defined. | |
public var body: some Commands { get } | |
/// The type of commands that represents the body of this command hierarchy. | |
/// | |
/// When you create custom commands, Swift infers this type from your | |
/// implementation of the required ``SwiftUI/Commands/body-swift.property`` | |
/// property. | |
public typealias Body = some Commands | |
} | |
/// The list style that describes the behavior and appearance of a | |
/// sidebar list. | |
/// | |
/// Do not use this type directly. Instead, use ``ListStyle/sidebar``. | |
@available(iOS 14.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct SidebarListStyle : ListStyle { | |
/// Creates a sidebar list style. | |
public init() | |
} | |
/// A gesture containing two gestures that can happen at the same time with | |
/// neither of them preceding the other. | |
/// | |
/// A simultaneous gesture is a container-event handler that evaluates its two | |
/// child gestures at the same time. Its value is a struct with two optional | |
/// values, each representing the phases of one of the two gestures. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct SimultaneousGesture<First, Second> : Gesture where First : Gesture, Second : Gesture { | |
/// The value of a simultaneous gesture that indicates which of its two | |
/// gestures receives events. | |
@frozen public struct Value { | |
/// The value of the first gesture. | |
public var first: First.Value? | |
/// The value of the second gesture. | |
public var second: Second.Value? | |
} | |
/// The first of two gestures that can happen simultaneously. | |
public var first: First | |
/// The second of two gestures that can happen simultaneously. | |
public var second: Second | |
/// Creates a gesture with two gestures that can receive updates or succeed | |
/// independently of each other. | |
/// | |
/// - Parameters: | |
/// - first: The first of two gestures that can happen simultaneously. | |
/// - second: The second of two gestures that can happen simultaneously. | |
@inlinable public init(_ first: First, _ second: Second) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension SimultaneousGesture.Value : Equatable where First.Value : Equatable, Second.Value : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: SimultaneousGesture<First, Second>.Value, b: SimultaneousGesture<First, Second>.Value) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension SimultaneousGesture.Value : Hashable where First.Value : Hashable, Second.Value : Hashable { | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
/// A control for selecting a value from a bounded linear range of values. | |
/// | |
/// A slider consists of a "thumb" image that the user moves between two | |
/// extremes of a linear "track". The ends of the track represent the minimum | |
/// and maximum possible values. As the user moves the thumb, the slider | |
/// updates its bound value. | |
/// | |
/// The following example shows a slider bound to the value `speed`. As the | |
/// slider updates this value, a bound ``Text`` view shows the value updating. | |
/// The `onEditingChanged` closure passed to the slider receives callbacks when | |
/// the user drags the slider. The example uses this to change the | |
/// color of the value text. | |
/// | |
/// @State private var speed = 50.0 | |
/// @State private var isEditing = false | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// Slider( | |
/// value: $speed, | |
/// in: 0...100, | |
/// onEditingChanged: { editing in | |
/// isEditing = editing | |
/// } | |
/// ) | |
/// Text("\(speed)") | |
/// .foregroundColor(isEditing ? .red : .blue) | |
/// } | |
/// } | |
/// | |
/// ![An unlabeled slider, with its thumb about one third of the way from the | |
/// minimum extreme. Below, a blue label displays the value | |
/// 33.045977.](SwiftUI-Slider-simple.png) | |
/// | |
/// You can also use a `step` parameter to provide incremental steps along the | |
/// path of the slider. For example, if you have a slider with a range of `0` to | |
/// `100`, and you set the `step` value to `5`, the slider's increments would be | |
/// `0`, `5`, `10`, and so on. The following example shows this approach, and | |
/// also adds optional minimum and maximum value labels. | |
/// | |
/// @State private var speed = 50.0 | |
/// @State private var isEditing = false | |
/// | |
/// var body: some View { | |
/// Slider( | |
/// value: $speed, | |
/// in: 0...100, | |
/// step: 5 | |
/// ) { | |
/// Text("Speed") | |
/// } minimumValueLabel: { | |
/// Text("0") | |
/// } maximumValueLabel: { | |
/// Text("100") | |
/// } onEditingChanged: { editing in | |
/// isEditing = editing | |
/// } | |
/// Text("\(speed)") | |
/// .foregroundColor(isEditing ? .red : .blue) | |
/// } | |
/// | |
/// ![A slider with labels show minimum and maximum values of 0 and 100, | |
/// respectively, with its thumb most of the way to the maximum extreme. Below, | |
/// a blue label displays the value | |
/// 85.000000.](SwiftUI-Slider-withStepAndLabels.png) | |
/// | |
/// The slider also uses the `step` to increase or decrease the value when a | |
/// VoiceOver user adjusts the slider with voice commands. | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
public struct Slider<Label, ValueLabel> : View where Label : View, ValueLabel : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
extension Slider { | |
/// Creates a slider to select a value from a given range, which displays | |
/// the provided labels. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// - minimumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - maximumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, @ViewBuilder minimumValueLabel: () -> ValueLabel, @ViewBuilder maximumValueLabel: () -> ValueLabel, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
/// Creates a slider to select a value from a given range, subject to a | |
/// step increment, which displays the provided labels. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - step: The distance between each valid value. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// - minimumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - maximumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, @ViewBuilder minimumValueLabel: () -> ValueLabel, @ViewBuilder maximumValueLabel: () -> ValueLabel, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
} | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
extension Slider where ValueLabel == EmptyView { | |
/// Creates a slider to select a value from a given range, which displays | |
/// the provided label. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
/// Creates a slider to select a value from a given range, subject to a | |
/// step increment, which displays the provided label. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - step: The distance between each valid value. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
} | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
extension Slider where Label == EmptyView, ValueLabel == EmptyView { | |
/// Creates a slider to select a value from a given range. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
/// Creates a slider to select a value from a given range, subject to a | |
/// step increment. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - step: The distance between each valid value. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
} | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
extension Slider { | |
/// Creates a slider to select a value from a given range, which displays | |
/// the provided labels. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// - minimumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - maximumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)") | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, minimumValueLabel: ValueLabel, maximumValueLabel: ValueLabel, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
/// Creates a slider to select a value from a given range, subject to a | |
/// step increment, which displays the provided labels. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - step: The distance between each valid value. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// - minimumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - maximumValueLabel: A view that describes `bounds.lowerBound`. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:minimumValueLabel:maximumValueLabel:onEditingChanged:)") | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, minimumValueLabel: ValueLabel, maximumValueLabel: ValueLabel, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
} | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
extension Slider where ValueLabel == EmptyView { | |
/// Creates a slider to select a value from a given range, which displays | |
/// the provided label. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:label:onEditingChanged:)") | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V> = 0...1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
/// Creates a slider to select a value from a given range, subject to a | |
/// step increment, which displays the provided label. | |
/// | |
/// - Parameters: | |
/// - value: The selected value within `bounds`. | |
/// - bounds: The range of the valid values. Defaults to `0...1`. | |
/// - step: The distance between each valid value. | |
/// - onEditingChanged: A callback for when editing begins and ends. | |
/// - label: A `View` that describes the purpose of the instance. Not all | |
/// slider styles show the label, but even in those cases, SwiftUI | |
/// uses the label for accessibility. For example, VoiceOver uses the | |
/// label to identify the purpose of the slider. | |
/// | |
/// The `value` of the created instance is equal to the position of | |
/// the given value within `bounds`, mapped into `0...1`. | |
/// | |
/// The slider calls `onEditingChanged` when editing begins and ends. For | |
/// example, on iOS, editing begins when the user starts to drag the thumb | |
/// along the slider's track. | |
@available(tvOS, unavailable) | |
@available(iOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)") | |
@available(watchOS, deprecated: 100000.0, renamed: "Slider(value:in:step:label:onEditingChanged:)") | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : BinaryFloatingPoint, V.Stride : BinaryFloatingPoint | |
} | |
/// A flexible space that expands along the major axis of its containing stack | |
/// layout, or on both axes if not contained in a stack. | |
/// | |
/// A spacer creates an adaptive view with no content that expands as much as | |
/// it can. For example, when placed within an ``HStack``, a spacer expands | |
/// horizontally as much as the stack allows, moving sibling views out of the | |
/// way, within the limits of the stack's size. | |
/// SwiftUI sizes a stack that doesn't contain a spacer up to the combined | |
/// ideal widths of the content of the stack's child views. | |
/// | |
/// The following example provides a simple checklist row to illustrate how you | |
/// can use a spacer: | |
/// | |
/// struct ChecklistRow: View { | |
/// let name: String | |
/// | |
/// var body: some View { | |
/// HStack { | |
/// Image(systemName: "checkmark") | |
/// Text(name) | |
/// } | |
/// .border(Color.blue) | |
/// } | |
/// } | |
/// | |
/// ![A figure of a blue rectangular border that marks the boundary of an | |
/// HStack, wrapping a checkmark image to the left of the name Megan. The | |
/// checkmark and name are centered vertically and separated by system | |
/// standard-spacing within the stack.](Spacer-1.png) | |
/// | |
/// Adding a spacer before the image creates an adaptive view with no content | |
/// that expands to push the image and text to the right side of the stack. | |
/// The stack also now expands to take as much space as the parent view allows, | |
/// shown by the blue border that indicates the boundary of the stack: | |
/// | |
/// struct ChecklistRow: View { | |
/// let name: String | |
/// | |
/// var body: some View { | |
/// HStack { | |
/// Spacer() | |
/// Image(systemName: "checkmark") | |
/// Text(name) | |
/// } | |
/// .border(Color.blue) | |
/// } | |
/// } | |
/// | |
/// ![A figure of a blue rectangular border that marks the boundary of an | |
/// HStack, wrapping a checkmark image to the left of the name Megan. The | |
/// checkmark and name are centered vertically, separated by system-standard | |
/// spacing, and pushed to the right side of the stack.](Spacer-2.png) | |
/// | |
/// Moving the spacer between the image and the name pushes those elements to | |
/// the left and right sides of the ``HStack``, respectively. Because the stack | |
/// contains the spacer, it expands to take as much horizontal space as the | |
/// parent view allows; the blue border indicates its size: | |
/// | |
/// struct ChecklistRow: View { | |
/// let name: String | |
/// | |
/// var body: some View { | |
/// HStack { | |
/// Image(systemName: "checkmark") | |
/// Spacer() | |
/// Text(name) | |
/// } | |
/// .border(Color.blue) | |
/// } | |
/// } | |
/// | |
/// ![A figure of a blue rectangular border that marks the boundary of an | |
/// HStack, wrapping a checkmark image to the left of the name Megan. The | |
/// checkmark and name are centered vertically, with the checkmark on the | |
/// left edge of the stack, and the text on the right side of the | |
/// stack.](Spacer-3.png) | |
/// | |
/// Adding two spacer views on the outside of the stack leaves the image and | |
/// text together, while the stack expands to take as much horizontal space | |
/// as the parent view allows: | |
/// | |
/// struct ChecklistRow: View { | |
/// let name: String | |
/// | |
/// var body: some View { | |
/// HStack { | |
/// Spacer() | |
/// Image(systemName: "checkmark") | |
/// Text(name) | |
/// Spacer() | |
/// } | |
/// .border(Color.blue) | |
/// } | |
/// } | |
/// | |
/// ![A figure of a blue rectangular border marks the boundary of an HStack, | |
/// wrapping a checkmark image to the left of text spelling the name Megan. | |
/// The checkmark and name are centered vertically, separated by | |
/// system-standard spacing, and centered horizontally | |
/// in the stack.](Spacer-4.png) | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Spacer { | |
/// The minimum length this spacer can be shrunk to, along the axis or axes | |
/// of expansion. | |
/// | |
/// If `nil`, the system default spacing between views is used. | |
public var minLength: CGFloat? | |
@inlinable public init(minLength: CGFloat? = nil) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Spacer : View { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Spacer : Sendable { | |
} | |
/// A navigation view style represented by a view stack that only shows a | |
/// single top view at a time. | |
/// | |
/// Do not use this type directly. Instead, use ``NavigationViewStyle/stack``. | |
@available(iOS 13.0, tvOS 13.0, watchOS 7.0, *) | |
@available(macOS, unavailable) | |
public struct StackNavigationViewStyle : NavigationViewStyle { | |
public init() | |
} | |
/// A property wrapper type that can read and write a value managed by SwiftUI. | |
/// | |
/// SwiftUI manages the storage of any property you declare as a state. When the | |
/// state value changes, the view invalidates its appearance and recomputes the | |
/// body. Use the state as the single source of truth for a given view. | |
/// | |
/// A ``State`` instance isn't the value itself; it's a means of reading and | |
/// writing the value. To access a state's underlying value, use its variable | |
/// name, which returns the ``State/wrappedValue`` property value. | |
/// | |
/// You should only access a state property from inside the view's body, or from | |
/// methods called by it. For this reason, declare your state properties as | |
/// private, to prevent clients of your view from accessing them. It is safe to | |
/// mutate state properties from any thread. | |
/// | |
/// To pass a state property to another view in the view hierarchy, use the | |
/// variable name with the `$` prefix operator. This retrieves a binding of the | |
/// state property from its ``State/projectedValue`` property. For example, in | |
/// the following code example `PlayerView` passes its state property | |
/// `isPlaying` to `PlayButton` using `$isPlaying`: | |
/// | |
/// struct PlayerView: View { | |
/// var episode: Episode | |
/// @State private var isPlaying: Bool = false | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// Text(episode.title) | |
/// Text(episode.showTitle) | |
/// PlayButton(isPlaying: $isPlaying) | |
/// } | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen @propertyWrapper public struct State<Value> : DynamicProperty { | |
/// Creates the state with an initial wrapped value. | |
/// | |
/// You don't call this initializer directly. Instead, declare a property | |
/// with the `@State` attribute, and provide an initial value; for example, | |
/// `@State private var isPlaying: Bool = false`. | |
/// | |
/// - Parameter wrappedValue: An initial wrappedValue for a state. | |
public init(wrappedValue value: Value) | |
/// Creates the state with an initial value. | |
/// | |
/// - Parameter value: An initial value of the state. | |
public init(initialValue value: Value) | |
/// The underlying value referenced by the state variable. | |
/// | |
/// This property provides primary access to the value's data. However, you | |
/// don't access `wrappedValue` directly. Instead, you use the property | |
/// variable created with the `@State` attribute. For example, in the | |
/// following code example the button's actions toggles the value of | |
/// `showingProfile`, which toggles `wrappedValue`: | |
/// | |
/// @State private var showingProfile = false | |
/// | |
/// var profileButton: some View { | |
/// Button(action: { self.showingProfile.toggle() }) { | |
/// Image(systemName: "person.crop.circle") | |
/// .imageScale(.large) | |
/// .accessibilityLabel(Text("User Profile")) | |
/// .padding() | |
/// } | |
/// } | |
/// | |
/// When a mutable binding value changes, the new value is immediately | |
/// available. However, updates to a view displaying the value happens | |
/// asynchronously, so the view may not show the change immediately. | |
public var wrappedValue: Value { get nonmutating set } | |
/// A binding to the state value. | |
/// | |
/// Use the projected value to pass a binding value down a view hierarchy. | |
/// To get the `projectedValue`, prefix the property variable with `$`. For | |
/// example, in the following code example `PlayerView` projects a binding | |
/// of the state property `isPlaying` to the `PlayButton` view using | |
/// `$isPlaying`. | |
/// | |
/// struct PlayerView: View { | |
/// var episode: Episode | |
/// @State private var isPlaying: Bool = false | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// Text(episode.title) | |
/// Text(episode.showTitle) | |
/// PlayButton(isPlaying: $isPlaying) | |
/// } | |
/// } | |
/// } | |
public var projectedValue: Binding<Value> { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension State where Value : ExpressibleByNilLiteral { | |
/// Creates a state without an initial value. | |
@inlinable public init() | |
} | |
/// A property wrapper type that instantiates an observable object. | |
/// | |
/// Create a state object in a ``SwiftUI/View``, ``SwiftUI/App``, or | |
/// ``SwiftUI/Scene`` by applying the `@StateObject` attribute to a property | |
/// declaration and providing an initial value that conforms to the | |
/// <doc://com.apple.documentation/documentation/Combine/ObservableObject> | |
/// protocol: | |
/// | |
/// @StateObject var model = DataModel() | |
/// | |
/// SwiftUI creates a new instance of the object only once for each instance of | |
/// the structure that declares the object. When published properties of the | |
/// observable object change, SwiftUI updates the parts of any view that depend | |
/// on those properties: | |
/// | |
/// Text(model.title) // Updates the view any time `title` changes. | |
/// | |
/// You can pass the state object into a property that has the | |
/// ``SwiftUI/ObservedObject`` attribute. You can alternatively add the object | |
/// to the environment of a view hierarchy by applying the | |
/// ``SwiftUI/View/environmentObject(_:)`` modifier: | |
/// | |
/// ContentView() | |
/// .environmentObject(model) | |
/// | |
/// If you create an environment object as shown in the code above, you can | |
/// read the object inside `ContentView` or any of its descendants | |
/// using the ``SwiftUI/EnvironmentObject`` attribute: | |
/// | |
/// @EnvironmentObject var model: DataModel | |
/// | |
/// Get a ``SwiftUI/Binding`` to one of the state object's properties using the | |
/// `$` operator. Use a binding when you want to create a two-way connection to | |
/// one of the object's properties. For example, you can let a | |
/// ``SwiftUI/Toggle`` control a Boolean value called `isEnabled` stored in the | |
/// model: | |
/// | |
/// Toggle("Enabled", isOn: $model.isEnabled) | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
@frozen @propertyWrapper public struct StateObject<ObjectType> : DynamicProperty where ObjectType : ObservableObject { | |
/// Creates a new state object with an initial wrapped value. | |
/// | |
/// You don’t call this initializer directly. Instead, declare a property | |
/// with the `@StateObject` attribute in a ``SwiftUI/View``, | |
/// ``SwiftUI/App``, or ``SwiftUI/Scene``, and provide an initial value: | |
/// | |
/// struct MyView: View { | |
/// @StateObject var model = DataModel() | |
/// | |
/// // ... | |
/// } | |
/// | |
/// SwiftUI creates only one instance of the state object for each | |
/// container instance that you declare. In the code above, SwiftUI | |
/// creates `model` only the first time it initializes a particular instance | |
/// of `MyView`. On the other hand, each different instance of `MyView` | |
/// receives a distinct copy of the data model. | |
/// | |
/// - Parameter thunk: An initial value for the state object. | |
@inlinable public init(wrappedValue thunk: @autoclosure @escaping () -> ObjectType) | |
/// The underlying value referenced by the state object. | |
/// | |
/// The wrapped value property provides primary access to the value's data. | |
/// However, you don't access `wrappedValue` directly. Instead, use the | |
/// property variable created with the `@StateObject` attribute: | |
/// | |
/// @StateObject var contact = Contact() | |
/// | |
/// var body: some View { | |
/// Text(contact.name) // Accesses contact's wrapped value. | |
/// } | |
/// | |
/// When you change a property of the wrapped value, you can access the new | |
/// value immediately. However, SwiftUI updates views displaying the value | |
/// asynchronously, so the user interface might not update immediately. | |
public var wrappedValue: ObjectType { get } | |
/// A projection of the state object that creates bindings to its | |
/// properties. | |
/// | |
/// Use the projected value to pass a binding value down a view hierarchy. | |
/// To get the projected value, prefix the property variable with `$`. For | |
/// example, you can get a binding to a model's `isEnabled` Boolean so that | |
/// a ``SwiftUI/Toggle`` view can control the value: | |
/// | |
/// struct MyView: View { | |
/// @StateObject var model = DataModel() | |
/// | |
/// var body: some View { | |
/// Toggle("Enabled", isOn: $model.isEnabled) | |
/// } | |
/// } | |
public var projectedValue: ObservedObject<ObjectType>.Wrapper { get } | |
} | |
/// A control that performs increment and decrement actions. | |
/// | |
/// Use a stepper control when you want the user to have granular control while | |
/// incrementing or decrementing a value. For example, you can use a stepper | |
/// to: | |
/// | |
/// * Change a value up or down by `1`. | |
/// * Operate strictly over a prescribed range. | |
/// * Step by specific amounts over a stepper's range of possible values. | |
/// | |
/// The example below uses an array that holds a number of ``Color`` values, | |
/// a local state variable, `value`, to set the control's background | |
/// color, and title label. When the user clicks or taps on the stepper's | |
/// increment or decrement buttons SwiftUI executes the relevant | |
/// closure that updates `value`, wrapping the `value` to prevent overflow. | |
/// SwiftUI then re-renders the view, updating the text and background | |
/// color to match the current index: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let colors: [Color] = [.orange, .red, .gray, .blue, | |
/// .green, .purple, .pink] | |
/// | |
/// func incrementStep() { | |
/// value += 1 | |
/// if value >= colors.count { value = 0 } | |
/// } | |
/// | |
/// func decrementStep() { | |
/// value -= 1 | |
/// if value < 0 { value = colors.count - 1 } | |
/// } | |
/// | |
/// var body: some View { | |
/// Stepper { | |
/// Text("Value: \(value) Color: \(colors[value].description)") | |
/// } onIncrement: { | |
/// incrementStep() | |
/// } onDecrement: { | |
/// decrementStep() | |
/// } | |
/// .padding(5) | |
/// .background(colors[value]) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that uses a text view for stepper's title | |
/// and that changes the background color of its view when incremented or | |
/// decremented. The view selects the new background color from a | |
/// predefined array of colors using the stepper's value as the | |
/// index.](SwiftUI-Stepper-increment-decrement-closures.png) | |
/// | |
/// The following example shows a stepper that displays the effect of | |
/// incrementing or decrementing a value with the step size of `step` with | |
/// the bounds defined by `range`: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let step = 5 | |
/// let range = 1...50 | |
/// | |
/// var body: some View { | |
/// Stepper(value: $value, | |
/// in: range, | |
/// step: step) { | |
/// Text("Current: \(value) in \(range.description) " + | |
/// "stepping by \(step)") | |
/// } | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper with a step size of five, and a | |
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png) | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct Stepper<Label> : View where Label : View { | |
/// Creates a stepper instance that performs the closures you provide when | |
/// the user increments or decrements the stepper. | |
/// | |
/// Use this initializer to create a control with a custom title that | |
/// executes closures you provide when the user clicks or taps the | |
/// stepper's increment or decrement buttons. | |
/// | |
/// The example below uses an array that holds a number of ``Color`` values, | |
/// a local state variable, `value`, to set the control's background | |
/// color, and title label. When the user clicks or taps on the stepper's | |
/// increment or decrement buttons SwiftUI executes the relevant | |
/// closure that updates `value`, wrapping the `value` to prevent overflow. | |
/// SwiftUI then re-renders the view, updating the text and background | |
/// color to match the current index: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let colors: [Color] = [.orange, .red, .gray, .blue, .green, | |
/// .purple, .pink] | |
/// | |
/// func incrementStep() { | |
/// value += 1 | |
/// if value >= colors.count { value = 0 } | |
/// } | |
/// | |
/// func decrementStep() { | |
/// value -= 1 | |
/// if value < 0 { value = colors.count - 1 } | |
/// } | |
/// | |
/// var body: some View { | |
/// Stepper { | |
/// Text("Value: \(value) Color: \(colors[value].description)") | |
/// } onIncrement: { | |
/// incrementStep() | |
/// } onDecrement: { | |
/// decrementStep() | |
/// } | |
/// .padding(5) | |
/// .background(colors[value]) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that uses a text view for stepper's title | |
/// and that changes the background color of its view when incremented or | |
/// decremented. The view selects the new background color from a | |
/// predefined array of colors using the stepper's value as the | |
/// index.](SwiftUI-Stepper-increment-decrement-closures.png) | |
/// | |
/// - Parameters: | |
/// - label: A view describing the purpose of this stepper. | |
/// - onIncrement: The closure to execute when the user clicks or taps | |
/// the control's plus button. | |
/// - onDecrement: The closure to execute when the user clicks or taps | |
/// the control's minus button. | |
/// - onEditingChanged: A closure called when editing begins and ends. | |
/// For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a `Stepper` which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
public init(@ViewBuilder label: () -> Label, onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in }) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Stepper { | |
/// Creates a stepper configured to increment or decrement a binding to a | |
/// value using a step value you provide. | |
/// | |
/// Use this initializer to create a stepper that increments or decrements | |
/// a bound value by a specific amount each time the user | |
/// clicks or taps the stepper's increment or decrement buttons. | |
/// | |
/// In the example below, a stepper increments or decrements `value` by the | |
/// `step` value of 5 at each click or tap of the control's increment or | |
/// decrement button: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 1 | |
/// let step = 5 | |
/// var body: some View { | |
/// Stepper(value: $value, | |
/// step: step) { | |
/// Text("Current value: \(value), step: \(step)") | |
/// } | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that increments or decrements a value by | |
/// a specified amount each time the user clicks or taps the stepper's | |
/// increment or decrement buttons.](SwiftUI-Stepper-value-step.png) | |
/// | |
/// - Parameters: | |
/// - value: The ``Binding`` to a value that you provide. | |
/// - step: The amount to increment or decrement `value` each time the | |
/// user clicks or taps the stepper's increment or decrement buttons. | |
/// Defaults to `1`. | |
/// - label: A view describing the purpose of this stepper. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a stepper which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<V>(value: Binding<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable | |
/// Creates a stepper configured to increment or decrement a binding to a | |
/// value using a step value and within a range of values you provide. | |
/// | |
/// Use this initializer to create a stepper that increments or decrements | |
/// a binding to value by the step size you provide within the given bounds. | |
/// By setting the bounds, you ensure that the value never goes below or | |
/// above the lowest or highest value, respectively. | |
/// | |
/// The example below shows a stepper that displays the effect of | |
/// incrementing or decrementing a value with the step size of `step` | |
/// with the bounds defined by `range`: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let step = 5 | |
/// let range = 1...50 | |
/// | |
/// var body: some View { | |
/// Stepper(value: $value, | |
/// in: range, | |
/// step: step) { | |
/// Text("Current: \(value) in \(range.description) " + | |
/// "stepping by \(step)") | |
/// } | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper with a step size of five, and a | |
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png) | |
/// | |
/// - Parameters: | |
/// - value: A ``Binding`` to a value that you provide. | |
/// - bounds: A closed range that describes the upper and lower bounds | |
/// permitted by the stepper. | |
/// - step: The amount to increment or decrement the stepper when the | |
/// user clicks or taps the stepper's increment or decrement buttons, | |
/// respectively. | |
/// - label: A view describing the purpose of this stepper. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a stepper which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, @ViewBuilder label: () -> Label, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable | |
} | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Stepper where Label == Text { | |
/// Creates a stepper that uses a title key and executes the closures | |
/// you provide when the user clicks or taps the stepper's increment and | |
/// decrement buttons. | |
/// | |
/// Use this initializer to create a stepper with a custom title that | |
/// executes closures you provide when either of the stepper's increment | |
/// or decrement buttons are pressed. This version of ``Stepper`` doesn't | |
/// take a binding to a value, nor does it allow you to specify a range of | |
/// acceptable values, or a step value -- it simply calls the closures you | |
/// provide when the control's buttons are pressed. | |
/// | |
/// The example below uses an array that holds a number of ``Color`` values, | |
/// a local state variable, `value`, to set the control's background | |
/// color, and title label. When the user clicks or taps on the stepper's | |
/// increment or decrement buttons SwiftUI executes the relevant | |
/// closure that updates `value`, wrapping the `value` to prevent overflow. | |
/// SwiftUI then re-renders the view, updating the text and background | |
/// color to match the current index: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let colors: [Color] = [.orange, .red, .gray, .blue, .green, | |
/// .purple, .pink] | |
/// | |
/// func incrementStep() { | |
/// value += 1 | |
/// if value >= colors.count { value = 0 } | |
/// } | |
/// | |
/// func decrementStep() { | |
/// value -= 1 | |
/// if value < 0 { value = colors.count - 1 } | |
/// } | |
/// | |
/// var body: some View { | |
/// Stepper("Value: \(value) Color: \(colors[value].description)", | |
/// onIncrement: incrementStep, | |
/// onDecrement: decrementStep) | |
/// .padding(5) | |
/// .background(colors[value]) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that uses a title key for the stepper's | |
/// localized title and that changes the background color of its view | |
/// when incremented or decremented selecting a color from a predefined | |
/// array using the stepper value as the | |
/// index.](SwiftUI-Stepper-increment-decrement-closures.png) | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the stepper's localized title describing | |
/// the purpose of the stepper. | |
/// - onIncrement: The closure to execute when the user clicks or taps the | |
/// control's plus button. | |
/// - onDecrement: The closure to execute when the user clicks or taps the | |
/// control's minus button. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a `Stepper` which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init(_ titleKey: LocalizedStringKey, onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in }) | |
/// Creates a stepper using a title string and that executes closures | |
/// you provide when the user clicks or taps the stepper's increment or | |
/// decrement buttons. | |
/// | |
/// Use `Stepper(_:onIncrement:onDecrement:onEditingChanged:)` to create a | |
/// control with a custom title that executes closures you provide when | |
/// the user clicks or taps on the stepper's increment or decrement buttons. | |
/// | |
/// The example below uses an array that holds a number of ``Color`` values, | |
/// a local state variable, `value`, to set the control's background | |
/// color, and title label. When the user clicks or taps on the stepper's | |
/// increment or decrement buttons SwiftUI executes the relevant | |
/// closure that updates `value`, wrapping the `value` to prevent overflow. | |
/// SwiftUI then re-renders the view, updating the text and background | |
/// color to match the current index: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let title: String | |
/// let colors: [Color] = [.orange, .red, .gray, .blue, .green, | |
/// .purple, .pink] | |
/// | |
/// func incrementStep() { | |
/// value += 1 | |
/// if value >= colors.count { value = 0 } | |
/// } | |
/// | |
/// func decrementStep() { | |
/// value -= 1 | |
/// if value < 0 { value = colors.count - 1 } | |
/// } | |
/// | |
/// var body: some View { | |
/// Stepper(title, onIncrement: incrementStep, onDecrement: decrementStep) | |
/// .padding(5) | |
/// .background(colors[value]) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that uses a string for the stepper's title | |
/// and that changes the background color of its view when incremented or | |
/// decremented selecting a color from a predefined array using the | |
/// stepper's value as the | |
/// index.](SwiftUI-Stepper-increment-decrement-closures.png) | |
/// | |
/// - Parameters: | |
/// - title: A string describing the purpose of the stepper. | |
/// - onIncrement: The closure to execute when the user clicks or taps the | |
/// control's plus button. | |
/// - onDecrement: The closure to execute when the user clicks or taps the | |
/// control's minus button. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a `Stepper` which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<S>(_ title: S, onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol | |
/// Creates a stepper with a title key and configured to increment and | |
/// decrement a binding to a value and step amount you provide. | |
/// | |
/// Use `Stepper(_:value:step:onEditingChanged:)` to create a stepper with a | |
/// custom title that increments or decrements a binding to value by the | |
/// step size you specify. | |
/// | |
/// In the example below, the stepper increments or decrements the binding | |
/// value by `5` each time the user clicks or taps on the control's | |
/// increment or decrement buttons, respectively: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 1 | |
/// let step = 5 | |
/// | |
/// var body: some View { | |
/// Stepper("Current value: \(value), step: \(step)", | |
/// value: $value, | |
/// step: step) | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that increments or decrements by 5 each | |
/// time the user clicks or taps on the control's increment or decrement | |
/// buttons, respectively.](SwiftUI-Stepper-value-step.png) | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the stepper's localized title describing | |
/// the purpose of the stepper. | |
/// - value: A ``Binding`` to a value that you provide. | |
/// - step: The amount to increment or decrement `value` each time the | |
/// user clicks or taps the stepper's plus or minus button, | |
/// respectively. Defaults to `1`. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the | |
/// increment or decrement buttons on a `Stepper` which causes the | |
/// execution of the `onEditingChanged` closure at the start and end | |
/// of the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable | |
/// Creates a stepper with a title and configured to increment and | |
/// decrement a binding to a value and step amount you provide. | |
/// | |
/// Use `Stepper(_:value:step:onEditingChanged:)` to create a stepper with a | |
/// custom title that increments or decrements a binding to value by the | |
/// step size you specify. | |
/// | |
/// In the example below, the stepper increments or decrements the binding | |
/// value by `5` each time one of the user clicks or taps the control's | |
/// increment or decrement buttons: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 1 | |
/// let step = 5 | |
/// let title: String | |
/// | |
/// var body: some View { | |
/// Stepper(title, value: $value, step: step) | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that increments or decrements by 1 each | |
/// time the control's buttons | |
/// are pressed.](SwiftUI-Stepper-value-step.png) | |
/// | |
/// - Parameters: | |
/// - title: A string describing the purpose of the stepper. | |
/// - value: The ``Binding`` to a value that you provide. | |
/// - step: The amount to increment or decrement `value` each time the | |
/// user clicks or taps the stepper's increment or decrement button, | |
/// respectively. Defaults to `1`. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the | |
/// increment or decrement buttons on a `Stepper` which causes the | |
/// execution of the `onEditingChanged` closure at the start and end | |
/// of the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<S, V>(_ title: S, value: Binding<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol, V : Strideable | |
/// Creates a stepper instance that increments and decrements a binding to | |
/// a value, by a step size and within a closed range that you provide. | |
/// | |
/// Use `Stepper(_:value:in:step:onEditingChanged:)` to create a stepper | |
/// that increments or decrements a value within a specific range of values | |
/// by a specific step size. In the example below, a stepper increments or | |
/// decrements a binding to value over a range of `1...50` by `5` at each | |
/// press of the stepper's increment or decrement buttons: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// @State private var titleKey = "Stepper" | |
/// | |
/// let step = 5 | |
/// let range = 1...50 | |
/// | |
/// var body: some View { | |
/// VStack(spacing: 20) { | |
/// Text("Current Stepper Value: \(value)") | |
/// Stepper(titleKey, value: $value, in: range, step: step) | |
/// } | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that increments or decrements within a | |
/// specified range and step size.](SwiftUI-Stepper-value-step-range.png) | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the stepper's localized title describing | |
/// the purpose of the stepper. | |
/// - value: A ``Binding`` to a value that your provide. | |
/// - bounds: A closed range that describes the upper and lower bounds | |
/// permitted by the stepper. | |
/// - step: The amount to increment or decrement `value` each time the | |
/// user clicks or taps the stepper's increment or decrement button, | |
/// respectively. Defaults to `1`. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a `Stepper` which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where V : Strideable | |
/// Creates a stepper instance that increments and decrements a binding to | |
/// a value, by a step size and within a closed range that you provide. | |
/// | |
/// Use `Stepper(_:value:in:step:onEditingChanged:)` to create a stepper | |
/// that increments or decrements a value within a specific range of values | |
/// by a specific step size. In the example below, a stepper increments or | |
/// decrements a binding to value over a range of `1...50` by `5` each time | |
/// the user clicks or taps the stepper's increment or decrement buttons: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let step = 5 | |
/// let range = 1...50 | |
/// | |
/// var body: some View { | |
/// Stepper("Current: \(value) in \(range.description) stepping by \(step)", | |
/// value: $value, | |
/// in: range, | |
/// step: step) | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that increments or decrements within a | |
/// specified range and step size.](SwiftUI-Stepper-value-step-range.png) | |
/// | |
/// - Parameters: | |
/// - title: A string describing the purpose of the stepper. | |
/// - value: A ``Binding`` to a value that your provide. | |
/// - bounds: A closed range that describes the upper and lower bounds | |
/// permitted by the stepper. | |
/// - step: The amount to increment or decrement `value` each time the | |
/// user clicks or taps the stepper's increment or decrement button, | |
/// respectively. Defaults to `1`. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a `Stepper` which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<S, V>(_ title: S, value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }) where S : StringProtocol, V : Strideable | |
} | |
@available(iOS 13.0, macOS 10.15, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
extension Stepper { | |
/// Creates a stepper instance that performs the closures you provide when | |
/// the user increments or decrements the stepper. | |
/// | |
/// Use this initializer to create a control with a custom title that | |
/// executes closures you provide when the user clicks or taps the | |
/// stepper's increment or decrement buttons. | |
/// | |
/// The example below uses an array that holds a number of ``Color`` values, | |
/// a local state variable, `value`, to set the control's background | |
/// color, and title label. When the user clicks or taps on the stepper's | |
/// increment or decrement buttons SwiftUI executes the relevant | |
/// closure that updates `value`, wrapping the `value` to prevent overflow. | |
/// SwiftUI then re-renders the view, updating the text and background | |
/// color to match the current index: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let colors: [Color] = [.orange, .red, .gray, .blue, .green, | |
/// .purple, .pink] | |
/// | |
/// func incrementStep() { | |
/// value += 1 | |
/// if value >= colors.count { value = 0 } | |
/// } | |
/// | |
/// func decrementStep() { | |
/// value -= 1 | |
/// if value < 0 { value = colors.count - 1 } | |
/// } | |
/// | |
/// var body: some View { | |
/// Stepper(onIncrement: incrementStep, | |
/// onDecrement: decrementStep) { | |
/// Text("Value: \(value) Color: \(colors[value].description)") | |
/// } | |
/// .padding(5) | |
/// .background(colors[value]) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that uses a text view for stepper's title | |
/// and that changes the background color of its view when incremented or | |
/// decremented. The view selects the new background color from a | |
/// predefined array of colors using the stepper's value as the | |
/// index.](SwiftUI-Stepper-increment-decrement-closures.png) | |
/// | |
/// - Parameters: | |
/// - onIncrement: The closure to execute when the user clicks or taps | |
/// the control's plus button. | |
/// - onDecrement: The closure to execute when the user clicks or taps | |
/// the control's minus button. | |
/// - onEditingChanged: A closure called when editing begins and ends. | |
/// For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a `Stepper` which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
/// - label: A view describing the purpose of this stepper. | |
@available(iOS, deprecated: 100000.0, renamed: "Stepper(label:onIncrement:onDecrement:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Stepper(label:onIncrement:onDecrement:onEditingChanged:)") | |
public init(onIncrement: (() -> Void)?, onDecrement: (() -> Void)?, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) | |
/// Creates a stepper configured to increment or decrement a binding to a | |
/// value using a step value you provide. | |
/// | |
/// Use this initializer to create a stepper that increments or decrements | |
/// a bound value by a specific amount each time the user | |
/// clicks or taps the stepper's increment or decrement buttons. | |
/// | |
/// In the example below, a stepper increments or decrements `value` by the | |
/// `step` value of 5 at each click or tap of the control's increment or | |
/// decrement button: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 1 | |
/// let step = 5 | |
/// var body: some View { | |
/// Stepper(value: $value, | |
/// step: step) { | |
/// Text("Current value: \(value), step: \(step)") | |
/// } | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper that increments or decrements a value by | |
/// a specified amount each time the user clicks or taps the stepper's | |
/// increment or decrement buttons.](SwiftUI-Stepper-value-step.png) | |
/// | |
/// - Parameters: | |
/// - value: The ``Binding`` to a value that you provide. | |
/// - step: The amount to increment or decrement `value` each time the | |
/// user clicks or taps the stepper's increment or decrement buttons. | |
/// Defaults to `1`. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a stepper which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
/// - label: A view describing the purpose of this stepper. | |
@available(iOS, deprecated: 100000.0, renamed: "Stepper(value:step:label:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Stepper(value:step:label:onEditingChanged:)") | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<V>(value: Binding<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : Strideable | |
/// Creates a stepper configured to increment or decrement a binding to a | |
/// value using a step value and within a range of values you provide. | |
/// | |
/// Use this initializer to create a stepper that increments or decrements | |
/// a binding to value by the step size you provide within the given bounds. | |
/// By setting the bounds, you ensure that the value never goes below or | |
/// above the lowest or highest value, respectively. | |
/// | |
/// The example below shows a stepper that displays the effect of | |
/// incrementing or decrementing a value with the step size of `step` | |
/// with the bounds defined by `range`: | |
/// | |
/// struct StepperView: View { | |
/// @State private var value = 0 | |
/// let step = 5 | |
/// let range = 1...50 | |
/// | |
/// var body: some View { | |
/// Stepper(value: $value, | |
/// in: range, | |
/// step: step) { | |
/// Text("Current: \(value) in \(range.description) " + | |
/// "stepping by \(step)") | |
/// } | |
/// .padding(10) | |
/// } | |
/// } | |
/// | |
/// ![A view displaying a stepper with a step size of five, and a | |
/// prescribed range of 1 though 50.](SwiftUI-Stepper-value-step-range.png) | |
/// | |
/// - Parameters: | |
/// - value: A ``Binding`` to a value that you provide. | |
/// - bounds: A closed range that describes the upper and lower bounds | |
/// permitted by the stepper. | |
/// - step: The amount to increment or decrement the stepper when the | |
/// user clicks or taps the stepper's increment or decrement buttons, | |
/// respectively. | |
/// - onEditingChanged: A closure that's called when editing begins and | |
/// ends. For example, on iOS, the user may touch and hold the increment | |
/// or decrement buttons on a stepper which causes the execution | |
/// of the `onEditingChanged` closure at the start and end of | |
/// the gesture. | |
/// - label: A view describing the purpose of this stepper. | |
@available(iOS, deprecated: 100000.0, renamed: "Stepper(value:in:step:label:onEditingChanged:)") | |
@available(macOS, deprecated: 100000.0, renamed: "Stepper(value:in:step:label:onEditingChanged:)") | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public init<V>(value: Binding<V>, in bounds: ClosedRange<V>, step: V.Stride = 1, onEditingChanged: @escaping (Bool) -> Void = { _ in }, @ViewBuilder label: () -> Label) where V : Strideable | |
} | |
/// The characteristics of a stroke that traces a path. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct StrokeStyle : Equatable { | |
/// The width of the stroked path. | |
public var lineWidth: CGFloat | |
/// The endpoint style of a line. | |
public var lineCap: CGLineCap | |
/// The join type of a line. | |
public var lineJoin: CGLineJoin | |
/// A threshold used to determine whether to use a bevel instead of a | |
/// miter at a join. | |
public var miterLimit: CGFloat | |
/// The lengths of painted and unpainted segments used to make a dashed line. | |
public var dash: [CGFloat] | |
/// How far into the dash pattern the line starts. | |
public var dashPhase: CGFloat | |
/// Creates a new stroke style from the given components. | |
/// | |
/// - Parameters: | |
/// - lineWidth: The width of the segment. | |
/// - lineCap: The endpoint style of a segment. | |
/// - lineJoin: The join type of a segment. | |
/// - miterLimit: The threshold used to determine whether to use a bevel | |
/// instead of a miter at a join. | |
/// - dash: The lengths of painted and unpainted segments used to make a | |
/// dashed line. | |
/// - dashPhase: How far into the dash pattern the line starts. | |
public init(lineWidth: CGFloat = 1, lineCap: CGLineCap = .butt, lineJoin: CGLineJoin = .miter, miterLimit: CGFloat = 10, dash: [CGFloat] = [CGFloat](), dashPhase: CGFloat = 0) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: StrokeStyle, b: StrokeStyle) -> Bool | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension StrokeStyle : Animatable { | |
/// The type defining the data to animate. | |
public typealias AnimatableData = AnimatablePair<CGFloat, AnimatablePair<CGFloat, CGFloat>> | |
/// The data to animate. | |
public var animatableData: StrokeStyle.AnimatableData | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension StrokeStyle : Sendable { | |
} | |
/// A semantic label describing the label of submission within a view hierarchy. | |
/// | |
/// A submit label is a description of a submission action provided to a | |
/// view hierarchy using the ``View/onSubmit(of:_:)`` modifier. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct SubmitLabel { | |
/// Defines a submit label with text of "Done". | |
public static var done: SubmitLabel { get } | |
/// Defines a submit label with text of "Go". | |
public static var go: SubmitLabel { get } | |
/// Defines a submit label with text of "Send". | |
public static var send: SubmitLabel { get } | |
/// Defines a submit label with text of "Join". | |
public static var join: SubmitLabel { get } | |
/// Defines a submit label with text of "Route". | |
public static var route: SubmitLabel { get } | |
/// Defines a submit label with text of "Search". | |
public static var search: SubmitLabel { get } | |
/// Defines a submit label with text of "Return". | |
public static var `return`: SubmitLabel { get } | |
/// Defines a submit label with text of "Next". | |
public static var next: SubmitLabel { get } | |
/// Defines a submit label with text of "Continue". | |
public static var `continue`: SubmitLabel { get } | |
} | |
/// A type that defines various triggers that result in the firing of a | |
/// submission action. | |
/// | |
/// These triggers may be provided to the ``View/onSubmit(of:_:)`` | |
/// modifier to alter which types of user behaviors trigger a provided | |
/// submission action. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct SubmitTriggers : OptionSet { | |
/// The raw type that can be used to represent all values of the conforming | |
/// type. | |
/// | |
/// Every distinct value of the conforming type has a corresponding unique | |
/// value of the `RawValue` type, but there may be values of the `RawValue` | |
/// type that don't have a corresponding value of the conforming type. | |
public typealias RawValue = Int | |
/// The corresponding value of the raw type. | |
/// | |
/// A new instance initialized with `rawValue` will be equivalent to this | |
/// instance. For example: | |
/// | |
/// enum PaperSize: String { | |
/// case A4, A5, Letter, Legal | |
/// } | |
/// | |
/// let selectedSize = PaperSize.Letter | |
/// print(selectedSize.rawValue) | |
/// // Prints "Letter" | |
/// | |
/// print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!) | |
/// // Prints "true" | |
public let rawValue: SubmitTriggers.RawValue | |
/// Creates a set of submit triggers. | |
public init(rawValue: SubmitTriggers.RawValue) | |
/// Defines triggers originating from text input controls like `TextField` | |
/// and `SecureField`. | |
public static let text: SubmitTriggers | |
/// Defines triggers originating from search fields constructed from | |
/// searchable modifiers. | |
/// | |
/// In the example below, only the search field or search completions | |
/// placed by the searchable modifier will trigger the view model to submit | |
/// its current search query. | |
/// | |
/// @StateObject var viewModel = ViewModel() | |
/// | |
/// NavigationView { | |
/// SidebarView() | |
/// DetailView() | |
/// } | |
/// .searchable( | |
/// text: $viewModel.searchText, | |
/// placement: .sidebar | |
/// ) { | |
/// SuggestionsView() | |
/// } | |
/// .onSubmit(of: .search) { | |
/// viewModel.submitCurrentSearchQuery() | |
/// } | |
/// | |
public static let search: SubmitTriggers | |
/// The type of the elements of an array literal. | |
public typealias ArrayLiteralElement = SubmitTriggers | |
/// The element type of the option set. | |
/// | |
/// To inherit all the default implementations from the `OptionSet` protocol, | |
/// the `Element` type must be `Self`, the default. | |
public typealias Element = SubmitTriggers | |
} | |
/// A view that subscribes to a publisher with an action. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct SubscriptionView<PublisherType, Content> : View where PublisherType : Publisher, Content : View, PublisherType.Failure == Never { | |
/// The content view. | |
public var content: Content | |
/// The `Publisher` that is being subscribed. | |
public var publisher: PublisherType | |
/// The `Action` executed when `publisher` emits an event. | |
public var action: (PublisherType.Output) -> Void | |
@inlinable public init(content: Content, publisher: PublisherType, action: @escaping (PublisherType.Output) -> Void) | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
/// A toggle style that displays a leading label and a trailing switch. | |
/// | |
/// Do not use this type directly. Instead, use ``ToggleStyle/switch``. | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
public struct SwitchToggleStyle : ToggleStyle { | |
/// Creates a switch toggle style. | |
public init() | |
/// Creates a switch style with a tint color. | |
@available(iOS, introduced: 14.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
@available(macOS, introduced: 11.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
@available(tvOS, unavailable) | |
@available(watchOS, introduced: 7.0, deprecated: 100000.0, message: "Use ``View/tint(_)`` instead.") | |
public init(tint: Color) | |
/// Creates a view representing the body of a toggle. | |
/// | |
/// The system calls this method for each ``Toggle`` instance in a view | |
/// hierarchy where this style is the current toggle style. | |
/// | |
/// - Parameter configuration: The properties of the toggle, such as its | |
/// label and its “on” state. | |
public func makeBody(configuration: SwitchToggleStyle.Configuration) -> some View | |
/// A view that represents the appearance and interaction of a toggle. | |
public typealias Body = some View | |
} | |
/// A symbol rendering mode. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct SymbolRenderingMode { | |
/// A mode that renders symbols as a single layer filled with the | |
/// foreground style. | |
/// | |
/// For example, you can render a filled exclamation mark triangle in | |
/// purple: | |
/// | |
/// Image(systemName: "exclamationmark.triangle.fill") | |
/// .symbolRenderingMode(.monochrome) | |
/// .foregroundStyle(Color.purple) | |
public static let monochrome: SymbolRenderingMode | |
/// A mode that renders symbols as multiple layers with their inherit | |
/// styles. | |
/// | |
/// The layers may be filled with their own inherent styles, or the | |
/// foreground style. For example, you can render a filled exclamation | |
/// mark triangle in its inherent colors, with yellow for the triangle and | |
/// white for the exclamation mark: | |
/// | |
/// Image(systemName: "exclamationmark.triangle.fill") | |
/// .symbolRenderingMode(.multicolor) | |
public static let multicolor: SymbolRenderingMode | |
/// A mode that renders symbols as multiple layers, with different opacities | |
/// applied to the foreground style. | |
/// | |
/// SwiftUI fills the first layer with the foreground style, and the others | |
/// the secondary, and tertiary variants of the foreground style. You can | |
/// specify these styles explicitly using the ``View/foregroundStyle(_:_:)`` | |
/// and ``View/foregroundStyle(_:_:_:)`` modifiers. If you only specify | |
/// a primary foreground style, SwiftUI automatically derives | |
/// the others from that style. For example, you can render a filled | |
/// exclamation mark triangle with purple as the tint color for the | |
/// exclamation mark, and lower opacity purple for the triangle: | |
/// | |
/// Image(systemName: "exclamationmark.triangle.fill") | |
/// .symbolRenderingMode(.hierarchical) | |
/// .foregroundStyle(Color.purple) | |
public static let hierarchical: SymbolRenderingMode | |
/// A mode that renders symbols as multiple layers, with different styles | |
/// applied to the layers. | |
/// | |
/// In this mode SwiftUI maps each successively defined layer in the image | |
/// to the next of the primary, secondary, and tertiary variants of the | |
/// foreground style. You can specify these styles explicitly using the | |
/// ``View/foregroundStyle(_:_:)`` and ``View/foregroundStyle(_:_:_:)`` | |
/// modifiers. If you only specify a primary foreground style, SwiftUI | |
/// automatically derives the others from that style. For example, you can | |
/// render a filled exclamation mark triangle with yellow as the tint color | |
/// for the exclamation mark, and fill the triangle with cyan: | |
/// | |
/// Image(systemName: "exclamationmark.triangle.fill") | |
/// .symbolRenderingMode(.palette) | |
/// .foregroundStyle(Color.yellow, Color.cyan) | |
/// | |
/// You can also omit the symbol rendering mode, as specifying multiple | |
/// foreground styles implies switching to palette rendering mode: | |
/// | |
/// Image(systemName: "exclamationmark.triangle.fill") | |
/// .foregroundStyle(Color.yellow, Color.cyan) | |
public static let palette: SymbolRenderingMode | |
} | |
/// A variant of a symbol. | |
/// | |
/// Many of the | |
/// [SF Symbols](https://developer.apple.com/design/human-interface-guidelines/sf-symbols/overview/) | |
/// that you can add to your app using an ``Image`` or a ``Label`` instance | |
/// have common variants, like a filled version or a version that's | |
/// contained within a circle. The symbol's name indicates the variant: | |
/// | |
/// VStack(alignment: .leading) { | |
/// Label("Default", systemImage: "heart") | |
/// Label("Fill", systemImage: "heart.fill") | |
/// Label("Circle", systemImage: "heart.circle") | |
/// Label("Circle Fill", systemImage: "heart.circle.fill") | |
/// } | |
/// | |
/// ![A screenshot showing an outlined heart, a filled heart, a heart in | |
/// a circle, and a filled heart in a circle, each with a text label | |
/// describing the symbol.](SymbolVariants-1) | |
/// | |
/// You can configure a part of your view hierarchy to use a particular variant | |
/// for all symbols in that view and its child views using `SymbolVariants`. | |
/// Add the ``View/symbolVariant(_:)`` modifier to a view to set a variant | |
/// for that view's environment. For example, you can use the modifier to | |
/// create the same set of labels as in the example above, using only the | |
/// base name of the symbol in the label declarations: | |
/// | |
/// VStack(alignment: .leading) { | |
/// Label("Default", systemImage: "heart") | |
/// Label("Fill", systemImage: "heart") | |
/// .symbolVariant(.fill) | |
/// Label("Circle", systemImage: "heart") | |
/// .symbolVariant(.circle) | |
/// Label("Circle Fill", systemImage: "heart") | |
/// .symbolVariant(.circle.fill) | |
/// } | |
/// | |
/// Alternatively, you can set the variant in the environment directly by | |
/// passing the ``EnvironmentValues/symbolVariants`` environment value to the | |
/// ``View/environment(_:_:)`` modifier: | |
/// | |
/// Label("Fill", systemImage: "heart") | |
/// .environment(\.symbolVariants, .fill) | |
/// | |
/// SwiftUI sets a variant for you in some environments. For example, SwiftUI | |
/// automatically applies the ``SymbolVariants/fill-swift.type.property`` | |
/// symbol variant for items that appear in the `content` closure of the | |
/// ``View/swipeActions(edge:allowsFullSwipe:content:)`` | |
/// method, or as the tab bar items of a ``TabView``. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct SymbolVariants : Hashable { | |
/// No variant for a symbol. | |
/// | |
/// Using this variant with the ``View/symbolVariant(_:)`` modifier doesn't | |
/// have any effect. Instead, to show a symbol that ignores the current | |
/// variant, directly set the ``EnvironmentValues/symbolVariants`` | |
/// environment value to `none` using the ``View/environment(_:_:)`` | |
/// modifer: | |
/// | |
/// HStack { | |
/// Image(systemName: "heart") | |
/// Image(systemName: "heart") | |
/// .environment(\.symbolVariants, .none) | |
/// } | |
/// .symbolVariant(.fill) | |
/// | |
/// ![A screenshot of two heart symbols. The first is filled while the | |
/// second is outlined.](SymbolVariants-none-1) | |
public static let none: SymbolVariants | |
/// A variant that encapsulates the symbol in a circle. | |
/// | |
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier | |
/// to draw symbols in a circle, for those symbols that have a circle | |
/// variant: | |
/// | |
/// VStack(spacing: 20) { | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// .symbolVariant(.circle) | |
/// } | |
/// | |
/// ![A screenshot showing two rows of four symbols each. Both rows contain | |
/// a flag, a heart, a bolt, and a star. The symbols in the second row are | |
/// versions of the symbols in the first row, but each is enclosed in a | |
/// circle.](SymbolVariants-circle-1) | |
public static let circle: SymbolVariants | |
/// A variant that encapsulates the symbol in a square. | |
/// | |
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier | |
/// to draw symbols in a square, for those symbols that have a square | |
/// variant: | |
/// | |
/// VStack(spacing: 20) { | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// .symbolVariant(.square) | |
/// } | |
/// | |
/// ![A screenshot showing two rows of four symbols each. Both rows contain | |
/// a flag, a heart, a bolt, and a star. The symbols in the second row are | |
/// versions of the symbols in the first row, but each is enclosed in a | |
/// square.](SymbolVariants-square-1) | |
public static let square: SymbolVariants | |
/// A variant that encapsulates the symbol in a rectangle. | |
/// | |
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier | |
/// to draw symbols in a rectangle, for those symbols that have a rectangle | |
/// variant: | |
/// | |
/// VStack(spacing: 20) { | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "plus") | |
/// Image(systemName: "minus") | |
/// Image(systemName: "xmark") | |
/// Image(systemName: "checkmark") | |
/// } | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "plus") | |
/// Image(systemName: "minus") | |
/// Image(systemName: "xmark") | |
/// Image(systemName: "checkmark") | |
/// } | |
/// .symbolVariant(.rectangle) | |
/// } | |
/// | |
/// ![A screenshot showing two rows of four symbols each. Both rows contain | |
/// a plus sign, a minus sign, a multiplication sign, and a check mark. | |
/// The symbols in the second row are versions of the symbols in the first | |
/// row, but each is enclosed in a rectangle.](SymbolVariants-rectangle-1) | |
public static let rectangle: SymbolVariants | |
/// A version of the variant that's encapsulated in a circle. | |
/// | |
/// Use this property to modify a variant like ``fill-swift.property`` | |
/// so that it's also contained in a circle: | |
/// | |
/// Label("Fill Circle", systemImage: "bolt") | |
/// .symbolVariant(.fill.circle) | |
/// | |
/// ![A screenshot of a label that shows a bolt in a filled circle | |
/// beside the words Fill Circle.](SymbolVariants-circle-2) | |
public var circle: SymbolVariants { get } | |
/// A version of the variant that's encapsulated in a square. | |
/// | |
/// Use this property to modify a variant like ``fill-swift.property`` | |
/// so that it's also contained in a square: | |
/// | |
/// Label("Fill Square", systemImage: "star") | |
/// .symbolVariant(.fill.square) | |
/// | |
/// ![A screenshot of a label that shows a star in a filled square | |
/// beside the words Fill Square.](SymbolVariants-square-2) | |
public var square: SymbolVariants { get } | |
/// A version of the variant that's encapsulated in a rectangle. | |
/// | |
/// Use this property to modify a variant like ``fill-swift.property`` | |
/// so that it's also contained in a rectangle: | |
/// | |
/// Label("Fill Rectangle", systemImage: "plus") | |
/// .symbolVariant(.fill.rectangle) | |
/// | |
/// ![A screenshot of a label that shows a plus sign in a filled rectangle | |
/// beside the words Fill Rectangle.](SymbolVariants-rectangle-2) | |
public var rectangle: SymbolVariants { get } | |
/// A variant that fills the symbol. | |
/// | |
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier | |
/// to draw filled symbols, for those symbols that have a filled variant: | |
/// | |
/// VStack(spacing: 20) { | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// .symbolVariant(.fill) | |
/// } | |
/// | |
/// ![A screenshot showing two rows of four symbols each. Both rows contain | |
/// a flag, a heart, a bolt, and a star. The symbols in the second row are | |
/// filled version of the symbols in the first row.](SymbolVariants-fill-1) | |
public static let fill: SymbolVariants | |
/// A filled version of the variant. | |
/// | |
/// Use this property to modify a shape variant like | |
/// ``circle-swift.type.property`` so that it's also filled: | |
/// | |
/// Label("Circle Fill", systemImage: "flag") | |
/// .symbolVariant(.circle.fill) | |
/// | |
/// ![A screenshot of a label that shows a flag in a filled circle | |
/// beside the words Circle Fill.](SymbolVariants-fill-2) | |
public var fill: SymbolVariants { get } | |
/// A variant that draws a slash through the symbol. | |
/// | |
/// Use this variant with a call to the ``View/symbolVariant(_:)`` modifier | |
/// to draw symbols with a slash, for those symbols that have such a | |
/// variant: | |
/// | |
/// VStack(spacing: 20) { | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// HStack(spacing: 20) { | |
/// Image(systemName: "flag") | |
/// Image(systemName: "heart") | |
/// Image(systemName: "bolt") | |
/// Image(systemName: "star") | |
/// } | |
/// .symbolVariant(.slash) | |
/// } | |
/// | |
/// ![A screenshot showing two rows of four symbols each. Both rows contain | |
/// a flag, a heart, a bolt, and a star. A slash is superimposed over | |
/// all the symbols in the second row.](SymbolVariants-slash-1) | |
public static let slash: SymbolVariants | |
/// A slashed version of the variant. | |
/// | |
/// Use this property to modify a shape variant like | |
/// ``circle-swift.type.property`` so that it's also covered by a slash: | |
/// | |
/// Label("Circle Slash", systemImage: "flag") | |
/// .symbolVariant(.circle.slash) | |
/// | |
/// ![A screenshot of a label that shows a flag in a circle with a | |
/// slash over it beside the words Circle Slash.](SymbolVariants-slash-2) | |
public var slash: SymbolVariants { get } | |
/// Returns a Boolean value that indicates whether the current variant | |
/// contains the specified variant. | |
/// | |
/// - Parameter other: A variant to look for in this variant. | |
/// - Returns: `true` if this variant contains `other`; otherwise, | |
/// `false`. | |
public func contains(_ other: SymbolVariants) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: SymbolVariants, b: SymbolVariants) -> Bool | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
/// A view that switches between multiple child views using interactive user | |
/// interface elements. | |
/// | |
/// To create a user interface with tabs, place views in a `TabView` and apply | |
/// the ``View/tabItem(_:)`` modifier to the contents of each tab. On iOS, you | |
/// can also use the ``View/badge(_:)`` modifier to assign a badge to each of | |
/// the tabs. The following creates a tab view with three tabs, the first of | |
/// which has a badge: | |
/// | |
/// TabView { | |
/// Text("The First Tab") | |
/// .badge(10) | |
/// .tabItem { | |
/// Image(systemName: "1.square.fill") | |
/// Text("First") | |
/// } | |
/// Text("Another Tab") | |
/// .tabItem { | |
/// Image(systemName: "2.square.fill") | |
/// Text("Second") | |
/// } | |
/// Text("The Last Tab") | |
/// .tabItem { | |
/// Image(systemName: "3.square.fill") | |
/// Text("Third") | |
/// } | |
/// } | |
/// .font(.headline) | |
/// | |
/// Tab views only support tab items of type ``Text``, ``Image``, or an image | |
/// followed by text. Passing any other type of view results in a visible but | |
/// empty tab item. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
public struct TabView<SelectionValue, Content> : View where SelectionValue : Hashable, Content : View { | |
/// Creates an instance that selects from content associated with | |
/// `Selection` values. | |
public init(selection: Binding<SelectionValue>?, @ViewBuilder content: () -> Content) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
extension TabView where SelectionValue == Int { | |
public init(@ViewBuilder content: () -> Content) | |
} | |
/// A specification for the appearance and interaction of a `TabView`. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public protocol TabViewStyle { | |
} | |
@available(iOS 14.0, tvOS 14.0, watchOS 7.0, *) | |
@available(macOS, unavailable) | |
extension TabViewStyle where Self == PageTabViewStyle { | |
/// A `TabViewStyle` that implements a paged scrolling `TabView`. | |
public static var page: PageTabViewStyle { get } | |
/// A `TabViewStyle` that implements a paged scrolling `TabView` with an | |
/// index display mode. | |
public static func page(indexDisplayMode: PageTabViewStyle.IndexDisplayMode) -> PageTabViewStyle | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 7.0, *) | |
extension TabViewStyle where Self == DefaultTabViewStyle { | |
/// The default `TabView` style. | |
public static var automatic: DefaultTabViewStyle { get } | |
} | |
/// A gesture that recognizes one or more taps. | |
/// | |
/// To recognize a tap gesture on a view, create and configure the gesture, and | |
/// then add it to the view using the ``View/gesture(_:including:)`` modifier. | |
/// The following code adds a tap gesture to a ``Circle`` that toggles the color | |
/// of the circle. | |
/// | |
/// struct TapGestureView: View { | |
/// @State var tapped = false | |
/// | |
/// var tap: some Gesture { | |
/// TapGesture(count: 1) | |
/// .onEnded { _ in self.tapped = !self.tapped } | |
/// } | |
/// | |
/// var body: some View { | |
/// Circle() | |
/// .fill(self.tapped ? Color.blue : Color.red) | |
/// .frame(width: 100, height: 100, alignment: .center) | |
/// .gesture(tap) | |
/// } | |
/// } | |
@available(iOS 13.0, macOS 10.15, watchOS 6.0, *) | |
@available(tvOS, unavailable) | |
public struct TapGesture : Gesture { | |
/// The required number of tap events. | |
public var count: Int | |
/// Creates a tap gesture with the number of required taps. | |
/// | |
/// - Parameter count: The required number of taps to complete the tap | |
/// gesture. | |
public init(count: Int = 1) | |
/// The type of gesture representing the body of `Self`. | |
public typealias Body = Never | |
/// The type representing the gesture's value. | |
public typealias Value = () | |
} | |
/// A view that displays one or more lines of read-only text. | |
/// | |
/// A text view draws a string in your app's user interface using a | |
/// ``Font/body`` font that's appropriate for the current platform. You can | |
/// choose a different standard font, like ``Font/title`` or ``Font/caption``, | |
/// using the ``View/font(_:)`` view modifier. | |
/// | |
/// Text("Hamlet") | |
/// .font(.title) | |
/// | |
/// ![A text view showing the name "Hamlet" in a title | |
/// font.](SwiftUI-Text-title.png) | |
/// | |
/// If you need finer control over the styling of the text, you can use the same | |
/// modifier to configure a system font or choose a custom font. You can also | |
/// apply view modifiers like ``Text/bold()`` or ``Text/italic()`` to further | |
/// adjust the formatting. | |
/// | |
/// Text("by William Shakespeare") | |
/// .font(.system(size: 12, weight: .light, design: .serif)) | |
/// .italic() | |
/// | |
/// ![A text view showing by William Shakespeare in a 12 point, light, italic, | |
/// serif font.](SwiftUI-Text-font.png) | |
/// | |
/// A text view always uses exactly the amount of space it needs to display its | |
/// rendered contents, but you can affect the view's layout. For example, you | |
/// can use the ``View/frame(width:height:alignment:)`` modifier to propose | |
/// specific dimensions to the view. If the view accepts the proposal but the | |
/// text doesn't fit into the available space, the view uses a combination of | |
/// wrapping, tightening, scaling, and truncation to make it fit. With a width | |
/// of `100` points but no constraint on the height, a text view might wrap a | |
/// long string: | |
/// | |
/// Text("To be, or not to be, that is the question:") | |
/// .frame(width: 100) | |
/// | |
/// ![A text view showing a quote from Hamlet split over three | |
/// lines.](SwiftUI-Text-split.png) | |
/// | |
/// Use modifiers like ``View/lineLimit(_:)``, ``View/allowsTightening(_:)``, | |
/// ``View/minimumScaleFactor(_:)``, and ``View/truncationMode(_:)`` to | |
/// configure how the view handles space constraints. For example, combining a | |
/// fixed width and a line limit of `1` results in truncation for text that | |
/// doesn't fit in that space: | |
/// | |
/// Text("Brevity is the soul of wit.") | |
/// .frame(width: 100) | |
/// .lineLimit(1) | |
/// | |
/// ![A text view showing a truncated quote from Hamlet starting Brevity is t | |
/// and ending with three dots.](SwiftUI-Text-truncated.png) | |
/// | |
/// ### Localizing Strings | |
/// | |
/// If you initialize a text view with a string literal, the view uses the | |
/// ``Text/init(_:tableName:bundle:comment:)`` initializer, which interprets the | |
/// string as a localization key and searches for the key in the table you | |
/// specify, or in the default table if you don't specify one. | |
/// | |
/// Text("pencil") // Searches the default table in the main bundle. | |
/// | |
/// For an app localized in both English and Spanish, the above view displays | |
/// "pencil" and "lápiz" for English and Spanish users, respectively. If the | |
/// view can't perform localization, it displays the key instead. For example, | |
/// if the same app lacks Danish localization, the view displays "pencil" for | |
/// users in that locale. Similarly, an app that lacks any localization | |
/// information displays "pencil" in any locale. | |
/// | |
/// To explicitly bypass localization for a string literal, use the | |
/// ``Text/init(verbatim:)`` initializer. | |
/// | |
/// Text(verbatim: "pencil") // Displays the string "pencil" in any locale. | |
/// | |
/// If you intialize a text view with a variable value, the view uses the | |
/// ``Text/init(_:)-9d1g4`` initializer, which doesn't localize the string. However, | |
/// you can request localization by creating a ``LocalizedStringKey`` instance | |
/// first, which triggers the ``Text/init(_:tableName:bundle:comment:)`` | |
/// initializer instead: | |
/// | |
/// // Don't localize a string variable... | |
/// Text(writingImplement) | |
/// | |
/// // ...unless you explicitly convert it to a localized string key. | |
/// Text(LocalizedStringKey(writingImplement)) | |
/// | |
/// When localizing a string variable, you can use the default table by omitting | |
/// the optional initialization parameters — as in the above example — just like | |
/// you might for a string literal. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public struct Text : Equatable { | |
/// Creates a text view that displays a string literal without localization. | |
/// | |
/// Use this initializer to create a text view with a string literal without | |
/// performing localization: | |
/// | |
/// Text(verbatim: "pencil") // Displays the string "pencil" in any locale. | |
/// | |
/// If you want to localize a string literal before displaying it, use the | |
/// ``Text/init(_:tableName:bundle:comment:)`` initializer instead. If you | |
/// want to display a string variable, use the ``Text/init(_:)-9d1g4`` | |
/// initializer, which also bypasses localization. | |
/// | |
/// - Parameter content: A string to display without localization. | |
@inlinable public init(verbatim content: String) | |
/// Creates a text view that displays a stored string without localization. | |
/// | |
/// Use this initializer to create a text view that displays — without | |
/// localization — the text in a string variable. | |
/// | |
/// Text(someString) // Displays the contents of `someString` without localization. | |
/// | |
/// SwiftUI doesn't call the `init(_:)` method when you initialize a text | |
/// view with a string literal as the input. Instead, a string literal | |
/// triggers the ``Text/init(_:tableName:bundle:comment:)`` method — which | |
/// treats the input as a ``LocalizedStringKey`` instance — and attempts to | |
/// perform localization. | |
/// | |
/// By default, SwiftUI assumes that you don't want to localize stored | |
/// strings, but if you do, you can first create a localized string key from | |
/// the value, and initialize the text view with that. Using a key as input | |
/// triggers the ``Text/init(_:tableName:bundle:comment:)`` method instead. | |
/// | |
/// - Parameter content: The string value to display without localization. | |
public init<S>(_ content: S) where S : StringProtocol | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Text, b: Text) -> Bool | |
} | |
extension Text { | |
/// Creates an instance that wraps an `Image`, suitable for concatenating | |
/// with other `Text` | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public init(_ image: Image) | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Text { | |
/// Creates a text view that displays the formatted representation | |
/// of a value. | |
/// | |
/// Use this initializer to create a text view that will format `subject` | |
/// using `formatter`. | |
public init<Subject>(_ subject: Subject, formatter: Formatter) where Subject : ReferenceConvertible | |
/// Creates a text view that displays the formatted representation | |
/// of a value. | |
/// | |
/// Use this initializer to create a text view that will format `subject` | |
/// using `formatter`. | |
public init<Subject>(_ subject: Subject, formatter: Formatter) where Subject : NSObject | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Text { | |
/// Creates a text view that displays the formatted representation of a | |
/// value. | |
/// | |
/// Use this initializer to create a text view that will format `input` | |
/// using `format`. | |
/// | |
/// - Parameters: | |
/// - input: The input to provide to the format style. | |
/// - format: The specific `FormatStyle` to use to convert the input | |
/// into a string. | |
public init<F>(_ input: F.FormatInput, format: F) where F : FormatStyle, F.FormatInput : Equatable, F.FormatOutput == String | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Text { | |
/// A predefined style used to display a `Date`. | |
public struct DateStyle { | |
/// A style displaying only the time component for a date. | |
/// | |
/// Text(event.startDate, style: .time) | |
/// | |
/// Example output: | |
/// 11:23PM | |
public static let time: Text.DateStyle | |
/// A style displaying a date. | |
/// | |
/// Text(event.startDate, style: .date) | |
/// | |
/// Example output: | |
/// June 3, 2019 | |
public static let date: Text.DateStyle | |
/// A style displaying a date as relative to now. | |
/// | |
/// Text(event.startDate, style: .relative) | |
/// | |
/// Example output: | |
/// 2 hours, 23 minutes | |
/// 1 year, 1 month | |
public static let relative: Text.DateStyle | |
/// A style displaying a date as offset from now. | |
/// | |
/// Text(event.startDate, style: .offset) | |
/// | |
/// Example output: | |
/// +2 hours | |
/// -3 months | |
public static let offset: Text.DateStyle | |
/// A style displaying a date as timer counting from now. | |
/// | |
/// Text(event.startDate, style: .timer) | |
/// | |
/// Example output: | |
/// 2:32 | |
/// 36:59:01 | |
public static let timer: Text.DateStyle | |
} | |
/// Creates an instance that displays localized dates and times using a specific style. | |
/// | |
/// - Parameters: | |
/// - date: The target date to display. | |
/// - style: The style used when displaying a date. | |
public init(_ date: Date, style: Text.DateStyle) | |
/// Creates an instance that displays a localized range between two dates. | |
/// | |
/// - Parameters: | |
/// - dates: The range of dates to display | |
public init(_ dates: ClosedRange<Date>) | |
/// Creates an instance that displays a localized time interval. | |
/// | |
/// Text(DateInterval(start: event.startDate, duration: event.duration)) | |
/// | |
/// Example output: | |
/// 9:30AM - 3:30PM | |
/// | |
/// - Parameters: | |
/// - interval: The date interval to display | |
public init(_ interval: DateInterval) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text { | |
/// Creates a text view that displays localized content identified by a key. | |
/// | |
/// Use this initializer to look for the `key` parameter in a localization | |
/// table and display the associated string value in the initialized text | |
/// view. If the initializer can't find the key in the table, or if no table | |
/// exists, the text view displays the string representation of the key | |
/// instead. | |
/// | |
/// Text("pencil") // Localizes the key if possible, or displays "pencil" if not. | |
/// | |
/// When you initialize a text view with a string literal, the view triggers | |
/// this initializer because it assumes you want the string localized, even | |
/// when you don't explicitly specify a table, as in the above example. If | |
/// you haven't provided localization for a particular string, you still get | |
/// reasonable behavior, because the initializer displays the key, which | |
/// typically contains the unlocalized string. | |
/// | |
/// If you initialize a text view with a string variable rather than a | |
/// string literal, the view triggers the ``Text/init(_:)-9d1g4`` | |
/// initializer instead, because it assumes that you don't want localization | |
/// in that case. If you do want to localize the value stored in a string | |
/// variable, you can choose to call the `init(_:tableName:bundle:comment:)` | |
/// initializer by first creating a ``LocalizedStringKey`` instance from the | |
/// string variable: | |
/// | |
/// Text(LocalizedStringKey(someString)) // Localizes the contents of `someString`. | |
/// | |
/// If you have a string literal that you don't want to localize, use the | |
/// ``Text/init(verbatim:)`` initializer instead. | |
/// | |
/// - Parameters: | |
/// - key: The key for a string in the table identified by `tableName`. | |
/// - tableName: The name of the string table to search. If `nil`, use the | |
/// table in the `Localizable.strings` file. | |
/// - bundle: The bundle containing the strings file. If `nil`, use the | |
/// main bundle. | |
/// - comment: Contextual information about this key-value pair. | |
public init(_ key: LocalizedStringKey, tableName: String? = nil, bundle: Bundle? = nil, comment: StaticString? = nil) | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Text { | |
/// Sets whether VoiceOver should always speak all punctuation in the text view. | |
/// | |
/// Use this modifier to control whether the system speaks punctuation characters | |
/// in the text. You might use this for code or other text where the punctuation is relevant, or where | |
/// you want VoiceOver to speak a verbatim transcription of the text you provide. For example, | |
/// given the text: | |
/// | |
/// Text("All the world's a stage, " + | |
/// "And all the men and women merely players;") | |
/// .speechAlwaysIncludesPunctuation() | |
/// | |
/// VoiceOver would speak "All the world apostrophe s a stage comma and all the men | |
/// and women merely players semicolon". | |
/// | |
/// By default, VoiceOver voices punctuation based on surrounding context. | |
/// | |
/// - Parameter value: A Boolean value that you set to `true` if | |
/// VoiceOver should speak all punctuation in the text. Defaults to `true`. | |
public func speechAlwaysIncludesPunctuation(_ value: Bool = true) -> Text | |
/// Sets whether VoiceOver should speak the contents of the text view character by character. | |
/// | |
/// Use this modifier when you want VoiceOver to speak text as individual letters, | |
/// character by character. This is important for text that is not meant to be spoken together, like: | |
/// - An acronym that isn't a word, like APPL, spoken as "A-P-P-L". | |
/// - A number representing a series of digits, like 25, spoken as "two-five" rather than "twenty-five". | |
/// | |
/// - Parameter value: A Boolean value that when `true` indicates | |
/// VoiceOver should speak text as individual characters. Defaults | |
/// to `true`. | |
public func speechSpellsOutCharacters(_ value: Bool = true) -> Text | |
/// Raises or lowers the pitch of spoken text. | |
/// | |
/// Use this modifier when you want to change the pitch of spoken text. | |
/// The value indicates how much higher or lower to change the pitch. | |
/// | |
/// - Parameter value: The amount to raise or lower the pitch. | |
/// Values between `-1` and `0` result in a lower pitch while | |
/// values between `0` and `1` result in a higher pitch. | |
/// The method clamps values to the range `-1` to `1`. | |
public func speechAdjustedPitch(_ value: Double) -> Text | |
/// Controls whether to queue pending announcements behind existing speech rather than | |
/// interrupting speech in progress. | |
/// | |
/// Use this modifier when you want affect the order in which the | |
/// accessibility system delivers spoken text. Announcements can | |
/// occur automatically when the label or value of an accessibility | |
/// element changes. | |
/// | |
/// - Parameter value: A Boolean value that determines if VoiceOver speaks | |
/// changes to text immediately or enqueues them behind existing speech. | |
/// Defaults to `true`. | |
public func speechAnnouncementsQueued(_ value: Bool = true) -> Text | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text { | |
/// Concatenates the text in two text views in a new text view. | |
/// | |
/// - Parameters: | |
/// - lhs: The first text view with text to combine. | |
/// - rhs: The second text view with text to combine. | |
/// | |
/// - Returns: A new text view containing the combined contents of the two | |
/// input text views. | |
public static func + (lhs: Text, rhs: Text) -> Text | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text { | |
/// The type of truncation to apply to a line of text when it's too long to | |
/// fit in the available space. | |
/// | |
/// When a text view contains more text than it's able to display, the view | |
/// might truncate the text and place an ellipsis (...) at the truncation | |
/// point. Use the ``View/truncationMode(_:)`` modifier with one of the | |
/// `TruncationMode` values to indicate which part of the text to | |
/// truncate, either at the beginning, in the middle, or at the end. | |
public enum TruncationMode { | |
/// Truncate at the beginning of the line. | |
/// | |
/// Use this kind of truncation to omit characters from the beginning of | |
/// the string. For example, you could truncate the English alphabet as | |
/// "...wxyz". | |
case head | |
/// Truncate at the end of the line. | |
/// | |
/// Use this kind of truncation to omit characters from the end of the | |
/// string. For example, you could truncate the English alphabet as | |
/// "abcd...". | |
case tail | |
/// Truncate in the middle of the line. | |
/// | |
/// Use this kind of truncation to omit characters from the middle of | |
/// the string. For example, you could truncate the English alphabet as | |
/// "ab...yz". | |
case middle | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Text.TruncationMode, b: Text.TruncationMode) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
/// A scheme for transforming the capitalization of characters within text. | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
public enum Case { | |
/// Displays text in all uppercase characters. | |
/// | |
/// For example, "Hello" would be displayed as "HELLO". | |
/// | |
/// - SeeAlso: `StringProtocol.uppercased(with:)` | |
case uppercase | |
/// Displays text in all lowercase characters. | |
/// | |
/// For example, "Hello" would be displayed as "hello". | |
/// | |
/// - SeeAlso: `StringProtocol.lowercased(with:)` | |
case lowercase | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Text.Case, b: Text.Case) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
extension Text { | |
/// Description of the style used to draw the line for `StrikethroughStyleAttribute` | |
/// and `UnderlineStyleAttribute`. | |
/// | |
/// Use this type to specify `underlineStyle` and `strikethroughStyle` | |
/// SwiftUI attributes of an `AttributedString`. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public struct LineStyle : Hashable { | |
/// Creates a line style. | |
/// | |
/// - Parameters: | |
/// - pattern: The pattern of the line. | |
/// - color: The color of the line. If not provided, the foreground | |
/// color of text is used. | |
public init(pattern: Text.LineStyle.Pattern = .solid, color: Color? = nil) | |
/// The pattern, that the line has. | |
public struct Pattern { | |
/// Draw a solid line. | |
public static let solid: Text.LineStyle.Pattern | |
/// Draw a line of dots. | |
public static let dot: Text.LineStyle.Pattern | |
/// Draw a line of dashes. | |
public static let dash: Text.LineStyle.Pattern | |
public static let dashDot: Text.LineStyle.Pattern | |
/// Draw a line of alternating dashes and two dots. | |
public static let dashDotDot: Text.LineStyle.Pattern | |
} | |
/// Draw a single solid line. | |
public static let single: Text.LineStyle | |
/// Creates a ``Text.LineStyle`` from ``NSUnderlineStyle``. | |
/// | |
/// > Note: Use this initializer only if you need to convert an existing | |
/// ``NSUnderlineStyle`` to a SwiftUI ``Text.LineStyle``. | |
/// Otherwise, create a ``Text.LineStyle`` using an | |
/// initializer like ``init(pattern:color:)``. | |
/// | |
/// - Parameter nsUnderlineStyle: A value of ``NSUnderlineStyle`` | |
/// to wrap with ``Text.LineStyle``. | |
/// | |
/// - Returns: A new ``Text.LineStyle`` or `nil` when | |
/// `nsUnderlineStyle` contains styles not supported by ``Text.LineStyle``. | |
public init?(nsUnderlineStyle: NSUnderlineStyle) | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Text.LineStyle, b: Text.LineStyle) -> Bool | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text : View { | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = Never | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text { | |
/// Sets the color of the text displayed by this view. | |
/// | |
/// Use this method to change the color of the text rendered by a text view. | |
/// | |
/// For example, you can display the names of the colors red, green, and | |
/// blue in their respective colors: | |
/// | |
/// HStack { | |
/// Text("Red").foregroundColor(.red) | |
/// Text("Green").foregroundColor(.green) | |
/// Text("Blue").foregroundColor(.blue) | |
/// } | |
/// | |
/// ![Three text views arranged horizontally, each containing | |
/// the name of a color displayed in that | |
/// color.](SwiftUI-Text-foregroundColor.png) | |
/// | |
/// - Parameter color: The color to use when displaying this text. | |
/// - Returns: A text view that uses the color value you supply. | |
public func foregroundColor(_ color: Color?) -> Text | |
/// Sets the default font for text in the view. | |
/// | |
/// Use `font(_:)` to apply a specific font to an individual | |
/// Text View, or all of the text views in a container. | |
/// | |
/// In the example below, the first text field has a font set directly, | |
/// while the font applied to the following container applies to all of the | |
/// text views inside that container: | |
/// | |
/// VStack { | |
/// Text("Font applied to a text view.") | |
/// .font(.largeTitle) | |
/// | |
/// VStack { | |
/// Text("These two text views have the same font") | |
/// Text("applied to their parent view.") | |
/// } | |
/// .font(.system(size: 16, weight: .light, design: .default)) | |
/// } | |
/// | |
/// | |
/// ![Applying a font to a single text view or a view container](SwiftUI-view-font.png) | |
/// | |
/// - Parameter font: The font to use when displaying this text. | |
/// - Returns: Text that uses the font you specify. | |
public func font(_ font: Font?) -> Text | |
/// Sets the font weight of the text. | |
/// | |
/// - Parameter weight: One of the available font weights. | |
/// | |
/// - Returns: Text that uses the font weight you specify. | |
public func fontWeight(_ weight: Font.Weight?) -> Text | |
/// Applies a bold font weight to the text. | |
/// | |
/// - Returns: Bold text. | |
public func bold() -> Text | |
/// Applies italics to the text. | |
/// | |
/// - Returns: Italic text. | |
public func italic() -> Text | |
/// Applies monospaced digits feature to the text. | |
/// | |
/// If the base font of the text view doesn't support | |
/// monospaced digits, the font remains unchanged. | |
/// | |
/// - Returns: Text with all digits of consistent width. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public func monospacedDigit() -> Text | |
/// Applies a strikethrough to the text. | |
/// | |
/// - Parameters: | |
/// - active: A Boolean value that indicates whether the text has a | |
/// strikethrough applied. | |
/// - color: The color of the strikethrough. If `color` is `nil`, the | |
/// strikethrough uses the default foreground color. | |
/// | |
/// - Returns: Text with a line through its center. | |
public func strikethrough(_ active: Bool = true, color: Color? = nil) -> Text | |
/// Applies an underline to the text. | |
/// | |
/// - Parameters: | |
/// - active: A Boolean value that indicates whether the text has an | |
/// underline. | |
/// - color: The color of the underline. If `color` is `nil`, the | |
/// underline uses the default foreground color. | |
/// | |
/// - Returns: Text with a line running along its baseline. | |
public func underline(_ active: Bool = true, color: Color? = nil) -> Text | |
/// Sets the spacing, or kerning, between characters. | |
/// | |
/// Kerning defines the offset, in points, that a text view should shift | |
/// characters from the default spacing. Use positive kerning to widen the | |
/// spacing between characters. Use negative kerning to tighten the spacing | |
/// between characters. | |
/// | |
/// VStack(alignment: .leading) { | |
/// Text("ABCDEF").kerning(-3) | |
/// Text("ABCDEF") | |
/// Text("ABCDEF").kerning(3) | |
/// } | |
/// | |
/// The last character in the first case, which uses negative kerning, | |
/// experiences cropping because the kerning affects the trailing edge of | |
/// the text view as well. | |
/// | |
/// ![Three text views showing character groups, with progressively | |
/// increasing spacing between the characters in each | |
/// group.](SwiftUI-Text-kerning-1.png) | |
/// | |
/// Kerning attempts to maintain ligatures. For example, the Hoefler Text | |
/// font uses a ligature for the letter combination _ffl_, as in the word | |
/// _raffle_, shown here with a small negative and a small positive kerning: | |
/// | |
/// ![Two text views showing the word raffle in the Hoefler Text font, the | |
/// first with small negative and the second with small positive kerning. | |
/// The letter combination ffl has the same shape in both variants because | |
/// it acts as a ligature.](SwiftUI-Text-kerning-2.png) | |
/// | |
/// The *ffl* letter combination keeps a constant shape as the other letters | |
/// move together or apart. Beyond a certain point in either direction, | |
/// however, kerning does disable nonessential ligatures. | |
/// | |
/// ![Two text views showing the word raffle in the Hoefler Text font, the | |
/// first with large negative and the second with large positive kerning. | |
/// The letter combination ffl does not act as a ligature in either | |
/// case.](SwiftUI-Text-kerning-3.png) | |
/// | |
/// - Important: If you add both the ``Text/tracking(_:)`` and | |
/// ``Text/kerning(_:)`` modifiers to a view, the view applies the | |
/// tracking and ignores the kerning. | |
/// | |
/// - Parameter kerning: The spacing to use between individual characters in | |
/// this text. | |
/// | |
/// - Returns: Text with the specified amount of kerning. | |
public func kerning(_ kerning: CGFloat) -> Text | |
/// Sets the tracking for the text. | |
/// | |
/// Tracking adds space, measured in points, between the characters in the | |
/// text view. A positive value increases the spacing between characters, | |
/// while a negative value brings the characters closer together. | |
/// | |
/// VStack(alignment: .leading) { | |
/// Text("ABCDEF").tracking(-3) | |
/// Text("ABCDEF") | |
/// Text("ABCDEF").tracking(3) | |
/// } | |
/// | |
/// The code above uses an unusually large amount of tracking to make it | |
/// easy to see the effect. | |
/// | |
/// ![Three text views showing character groups with progressively | |
/// increasing spacing between the characters in each | |
/// group.](SwiftUI-Text-tracking.png) | |
/// | |
/// The effect of tracking resembles that of the ``Text/kerning(_:)`` | |
/// modifier, but adds or removes trailing whitespace, rather than changing | |
/// character offsets. Also, using any nonzero amount of tracking disables | |
/// nonessential ligatures, whereas kerning attempts to maintain ligatures. | |
/// | |
/// - Important: If you add both the ``Text/tracking(_:)`` and | |
/// ``Text/kerning(_:)`` modifiers to a view, the view applies the | |
/// tracking and ignores the kerning. | |
/// | |
/// - Parameter tracking: The amount of additional space, in points, that | |
/// the view should add to each character cluster after layout. | |
/// | |
/// - Returns: Text with the specified amount of tracking. | |
public func tracking(_ tracking: CGFloat) -> Text | |
/// Sets the vertical offset for the text relative to its baseline. | |
/// | |
/// Change the baseline offset to move the text in the view (in points) up | |
/// or down relative to its baseline. The bounds of the view expand to | |
/// contain the moved text. | |
/// | |
/// HStack(alignment: .top) { | |
/// Text("Hello") | |
/// .baselineOffset(-10) | |
/// .border(Color.red) | |
/// Text("Hello") | |
/// .border(Color.green) | |
/// Text("Hello") | |
/// .baselineOffset(10) | |
/// .border(Color.blue) | |
/// } | |
/// .background(Color(white: 0.9)) | |
/// | |
/// By drawing a border around each text view, you can see how the text | |
/// moves, and how that affects the view. | |
/// | |
/// ![Three text views, each with the word "Hello" outlined by a border and | |
/// aligned along the top edges. The first and last are larger than the | |
/// second, with padding inside the border above the word "Hello" in the | |
/// first case, and padding inside the border below the word in the last | |
/// case.](SwiftUI-Text-baselineOffset.png) | |
/// | |
/// The first view, with a negative offset, grows downward to handle the | |
/// lowered text. The last view, with a positive offset, grows upward. The | |
/// enclosing ``HStack`` instance, shown in gray, ensures all the text views | |
/// remain aligned at their top edge, regardless of the offset. | |
/// | |
/// - Parameter baselineOffset: The amount to shift the text vertically (up | |
/// or down) relative to its baseline. | |
/// | |
/// - Returns: Text that's above or below its baseline. | |
public func baselineOffset(_ baselineOffset: CGFloat) -> Text | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Text { | |
/// Sets an accessibility text content type. | |
/// | |
/// Use this modifier to set the content type of this accessibility | |
/// element. Assistive technologies can use this property to choose | |
/// an appropriate way to output the text. For example, when | |
/// encountering a source coding context, VoiceOver could | |
/// choose to speak all punctuation. | |
/// | |
/// If you don't set a value with this method, the default content type | |
/// is ``AccessibilityTextContentType/plain``. | |
/// | |
/// - Parameter value: The accessibility content type from the available | |
/// ``AccessibilityTextContentType`` options. | |
public func accessibilityTextContentType(_ value: AccessibilityTextContentType) -> Text | |
/// Sets the accessibility level of this heading. | |
/// | |
/// Use this modifier to set the level of this heading in relation to other headings. The system speaks | |
/// the level number of levels ``AccessibilityHeadingLevel/h1`` through | |
/// ``AccessibilityHeadingLevel/h6`` alongside the text. | |
/// | |
/// The default heading level if you don't use this modifier | |
/// is ``AccessibilityHeadingLevel/unspecified``. | |
/// | |
/// - Parameter level: The heading level to associate with this element | |
/// from the available ``AccessibilityHeadingLevel`` levels. | |
public func accessibilityHeading(_ level: AccessibilityHeadingLevel) -> Text | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an alternative accessibility label | |
/// to the text that is displayed. For example, you can give an alternate label to a navigation title: | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// ContentView() | |
/// .navigationTitle(Text("").accessibilityLabel("Inbox")) | |
/// } | |
/// } | |
/// | |
/// You can't style the label that you add | |
/// | |
/// - Parameter label: The text view to add the label to. | |
public func accessibilityLabel(_ label: Text) -> Text | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an alternative accessibility label to the text that is displayed. | |
/// For example, you can give an alternate label to a navigation title: | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// ContentView() | |
/// .navigationTitle(Text("").accessibilityLabel("Inbox")) | |
/// } | |
/// } | |
/// | |
/// - Parameter labelKey: The string key for the alternative | |
/// accessibility label. | |
public func accessibilityLabel(_ labelKey: LocalizedStringKey) -> Text | |
/// Adds a label to the view that describes its contents. | |
/// | |
/// Use this method to provide an alternative accessibility label to the text that is displayed. | |
/// For example, you can give an alternate label to a navigation title: | |
/// | |
/// var body: some View { | |
/// NavigationView { | |
/// ContentView() | |
/// .navigationTitle(Text("").accessibilityLabel("Inbox")) | |
/// } | |
/// } | |
/// | |
/// - Parameter label: The string for the alternative accessibility label. | |
public func accessibilityLabel<S>(_ label: S) -> Text where S : StringProtocol | |
} | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
extension Text { | |
/// Creates a text view that displays styled attributed content. | |
/// | |
/// Use this initializer to style text according to its attributes, | |
/// which take precedence over styles added by view modifiers. | |
/// For example, the attributed text in the following example appears in blue: | |
/// | |
/// var content: AttributedString { | |
/// var attributedString = AttributedString("Blue text") | |
/// attributedString.foregroundColor = .blue | |
/// return attributedString | |
/// } | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// Text(content) | |
/// Text("Red text") | |
/// } | |
/// .foregroundColor(.red) | |
/// } | |
/// | |
/// - Parameters: | |
/// - attributedContent: The content to be displayed, | |
/// styled according to its attributes. | |
/// | |
/// Text is styled based on attributes in SwiftUI scope or their equivalent attributes | |
/// in UIKit/AppKit scopes. SwiftUI attributes take precedence over their | |
/// equivalents in other scopes. | |
public init(_ attributedContent: AttributedString) | |
} | |
extension Text.DateStyle : Equatable { | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: Text.DateStyle, b: Text.DateStyle) -> Bool | |
} | |
extension Text.DateStyle : Codable { | |
/// Encodes this value into the given encoder. | |
/// | |
/// If the value fails to encode anything, `encoder` will encode an empty | |
/// keyed container in its place. | |
/// | |
/// This function throws an error if any values are invalid for the given | |
/// encoder's format. | |
/// | |
/// - Parameter encoder: The encoder to write data to. | |
public func encode(to encoder: Encoder) throws | |
/// Creates a new instance by decoding from the given decoder. | |
/// | |
/// This initializer throws an error if reading from the decoder fails, or | |
/// if the data read is corrupted or otherwise invalid. | |
/// | |
/// - Parameter decoder: The decoder to read data from. | |
public init(from decoder: Decoder) throws | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text.TruncationMode : Equatable { | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension Text.TruncationMode : Hashable { | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Text.Case : Equatable { | |
} | |
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *) | |
extension Text.Case : Hashable { | |
} | |
/// Aligns the child view within its bounds given anchor types | |
/// | |
/// Child sizing: Respects the child's preferred size on the aligned axes. The child fills the context bounds on unaligned axes. | |
/// | |
/// Preferred size: Child's preferred size | |
/// An alignment position for text along the horizontal axis. | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
@frozen public enum TextAlignment : Hashable, CaseIterable { | |
case leading | |
case center | |
case trailing | |
/// Returns a Boolean value indicating whether two values are equal. | |
/// | |
/// Equality is the inverse of inequality. For any values `a` and `b`, | |
/// `a == b` implies that `a != b` is `false`. | |
/// | |
/// - Parameters: | |
/// - lhs: A value to compare. | |
/// - rhs: Another value to compare. | |
public static func == (a: TextAlignment, b: TextAlignment) -> Bool | |
/// Hashes the essential components of this value by feeding them into the | |
/// given hasher. | |
/// | |
/// Implement this method to conform to the `Hashable` protocol. The | |
/// components used for hashing must be the same as the components compared | |
/// in your type's `==` operator implementation. Call `hasher.combine(_:)` | |
/// with each of these components. | |
/// | |
/// - Important: Never call `finalize()` on `hasher`. Doing so may become a | |
/// compile-time error in the future. | |
/// | |
/// - Parameter hasher: The hasher to use when combining the components | |
/// of this instance. | |
public func hash(into hasher: inout Hasher) | |
/// A type that can represent a collection of all values of this type. | |
public typealias AllCases = [TextAlignment] | |
/// A collection of all values of this type. | |
public static var allCases: [TextAlignment] { get } | |
/// The hash value. | |
/// | |
/// Hash values are not guaranteed to be equal across different executions of | |
/// your program. Do not save hash values to use during a future execution. | |
/// | |
/// - Important: `hashValue` is deprecated as a `Hashable` requirement. To | |
/// conform to `Hashable`, implement the `hash(into:)` requirement instead. | |
public var hashValue: Int { get } | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension TextAlignment : Sendable { | |
} | |
/// A built-in group of commands for searching, editing, and transforming | |
/// selections of text. | |
/// | |
/// These commands are optional and can be explicitly requested by passing a | |
/// value of this type to the `Scene.commands(_:)` modifier. | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct TextEditingCommands : Commands { | |
/// A new value describing the built-in text-editing commands. | |
public init() | |
/// The contents of the command hierarchy. | |
/// | |
/// For any commands that you create, provide a computed `body` property | |
/// that defines the scene as a composition of other scenes. You can | |
/// assemble a command hierarchy from primitive commands that SwiftUI | |
/// provides, as well as other commands that you've defined. | |
public var body: some Commands { get } | |
/// The type of commands that represents the body of this command hierarchy. | |
/// | |
/// When you create custom commands, Swift infers this type from your | |
/// implementation of the required ``SwiftUI/Commands/body-swift.property`` | |
/// property. | |
public typealias Body = some Commands | |
} | |
/// A view that can display and edit long-form text. | |
/// | |
/// A text editor view allows you to display and edit multiline, scrollable | |
/// text in your app's user interface. By default, the text editor view styles | |
/// the text using characteristics inherited from the environment, like | |
/// ``View/font(_:)``, ``View/foregroundColor(_:)``, and | |
/// ``View/multilineTextAlignment(_:)``. | |
/// | |
/// You create a text editor by adding a `TextEditor` instance to the | |
/// body of your view, and initialize it by passing in a | |
/// ``Binding`` to a string variable in your app: | |
/// | |
/// struct TextEditingView: View { | |
/// @State private var fullText: String = "This is some editable text..." | |
/// | |
/// var body: some View { | |
/// TextEditor(text: $fullText) | |
/// } | |
/// } | |
/// | |
/// To style the text, use the standard view modifiers to configure a system | |
/// font, set a custom font, or change the color of the view's text. | |
/// | |
/// In this example, the view renders the editor's text in gray with a | |
/// custom font: | |
/// | |
/// struct TextEditingView: View { | |
/// @State private var fullText: String = "This is some editable text..." | |
/// | |
/// var body: some View { | |
/// TextEditor(text: $fullText) | |
/// .foregroundColor(Color.gray) | |
/// .font(.custom("HelveticaNeue", size: 13)) | |
/// } | |
/// } | |
/// | |
/// If you want to change the spacing or font scaling aspects of the text, you | |
/// can use modifiers like ``View/lineLimit(_:)``, | |
/// ``View/lineSpacing(_:)``, and ``View/minimumScaleFactor(_:)`` to configure | |
/// how the view displays text depending on the space constraints. For example, | |
/// here the ``View/lineSpacing(_:)`` modifier sets the spacing between lines | |
/// to 5 points: | |
/// | |
/// struct TextEditingView: View { | |
/// @State private var fullText: String = "This is some editable text..." | |
/// | |
/// var body: some View { | |
/// TextEditor(text: $fullText) | |
/// .foregroundColor(Color.gray) | |
/// .font(.custom("HelveticaNeue", size: 13)) | |
/// .lineSpacing(5) | |
/// } | |
/// } | |
@available(iOS 14.0, macOS 11.0, *) | |
@available(tvOS, unavailable) | |
@available(watchOS, unavailable) | |
public struct TextEditor : View { | |
/// Creates a plain text editor. | |
/// | |
/// Use a ``TextEditor`` instance to create a view in which users can enter | |
/// and edit long-form text. | |
/// | |
/// In this example, the text editor renders gray text using the 13 | |
/// point Helvetica Neue font with 5 points of spacing between each line: | |
/// | |
/// struct TextEditingView: View { | |
/// @State private var fullText: String = "This is some editable text..." | |
/// | |
/// var body: some View { | |
/// TextEditor(text: $fullText) | |
/// .foregroundColor(Color.gray) | |
/// .font(.custom("HelveticaNeue", size: 13)) | |
/// .lineSpacing(5) | |
/// } | |
/// } | |
/// | |
/// You can define the styling for the text within the view, including the | |
/// text color, font, and line spacing. You define these styles by applying | |
/// standard view modifiers to the view. | |
/// | |
/// The default text editor doesn't support rich text, such as styling of | |
/// individual elements within the editor's view. The styles you set apply | |
/// globally to all text in the view. | |
/// | |
/// - Parameter text: A ``Binding`` to the variable containing the | |
/// text to edit. | |
public init(text: Binding<String>) | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
/// A control that displays an editable text interface. | |
/// | |
/// You create a text field with a label and a binding to a value. If the | |
/// value is a string, the text field updates this value continuously as the | |
/// user types or otherwise edits the text in the field. For non-string types, | |
/// it updates the value when the user commits their edits, such as by pressing | |
/// the Return key. | |
/// | |
/// The text field also allows you to provide two closures that customize its | |
/// behavior. The `onEditingChanged` property informs your app when the user | |
/// begins or ends editing the text. The `onCommit` property executes when the | |
/// user commits their edits. | |
/// | |
/// The following example shows a text field to accept a username, and a | |
/// ``Text`` view below it that shadows the continuously-updated value | |
/// of `username`. The ``Text`` view changes color as the user begins and ends | |
/// editing, and committing the text calls an internal `validate(name:)` method. | |
/// | |
/// @State private var username: String = "" | |
/// @State private var isEditing = false | |
/// | |
/// var body: some View { | |
/// TextField( | |
/// "User name (email address)", | |
/// text: $username | |
/// ) { isEditing in | |
/// self.isEditing = isEditing | |
/// } onCommit: { | |
/// validate(name: username) | |
/// } | |
/// .autocapitalization(.none) | |
/// .disableAutocorrection(true) | |
/// .border(Color(UIColor.separator)) | |
/// Text(username) | |
/// .foregroundColor(isEditing ? .red : .blue) | |
/// } | |
/// | |
/// ![A text field showing the typed email mruiz2@icloud.com, with a text | |
/// view below it also showing this value.](SwiftUI-TextField-echoText.png) | |
/// | |
/// The bound value doesn't have to be a string. By using a | |
/// <doc://com.apple.documentation/documentation/Foundation/Formatter>, | |
/// you can bind the text field to a non-string type, using the formatter | |
/// to convert the typed text into an instance of the bound type. The following | |
/// example uses a | |
/// <doc://com.apple.documentation/documentation/Foundation/PersonNameComponentsFormatter> | |
/// to convert the name typed in the text field to a | |
/// <doc://com.apple.documentation/documentation/Foundation/PersonNameComponents> | |
/// instance. A ``Text`` view below the text field shows the debug description | |
/// string of this instance. | |
/// | |
/// @State private var nameComponents = PersonNameComponents() | |
/// | |
/// var body: some View { | |
/// let nameFormatter = PersonNameComponentsFormatter() | |
/// TextField( | |
/// "Proper name", | |
/// value: $nameComponents, | |
/// formatter: nameFormatter, | |
/// onCommit: { | |
/// validate(components: nameComponents) | |
/// }) | |
/// .disableAutocorrection(true) | |
/// .border(Color(UIColor.separator)) | |
/// Text(nameComponents.debugDescription) | |
/// } | |
/// | |
/// ![A text field showing the typed name Maria Ruiz, with a text view below | |
/// it showing the string givenName:Maria | |
/// familyName:Ruiz.](SwiftUI-TextField-nameComponents.png) | |
/// | |
/// ### Text Field Prompts | |
/// | |
/// A text field may be provided an explicit prompt to guide users on what | |
/// text they should provide. Each text field style determines where and | |
/// when a prompt and label may be used. For example, a form on macOS will | |
/// always place the label alongside the leading edge of the field and will | |
/// use a prompt, when available, as placeholder text within the field itself. | |
/// In the same context on iOS, the prompt or label will be used as placeholder | |
/// text depending on whether a prompt is provided. | |
/// | |
/// Form { | |
/// TextField(text: $username, prompt: Text("Required")) { | |
/// Text("Username") | |
/// } | |
/// SecureField(text: $username, prompt: Text("Required")) { | |
/// Text("Password") | |
/// } | |
/// } | |
/// | |
/// ### Styling Text Fields | |
/// | |
/// SwiftUI provides a default text field style that reflects an appearance and | |
/// behavior appropriate to the platform. The default style also takes the | |
/// current context into consideration, like whether the text field is in a | |
/// container that presents text fields with a special style. Beyond this, you | |
/// can customize the appearance and interaction of text fields using the | |
/// ``View/textFieldStyle(_:)`` modifier, passing in an instance of | |
/// ``TextFieldStyle``. The following example applies the | |
/// ``TextFieldStyle/roundedBorder`` style to both text fields within a ``VStack``. | |
/// | |
/// @State private var givenName: String = "" | |
/// @State private var familyName: String = "" | |
/// | |
/// var body: some View { | |
/// VStack { | |
/// TextField( | |
/// "Given Name", | |
/// text: $givenName) | |
/// .disableAutocorrection(true) | |
/// TextField( | |
/// "Family Name", | |
/// text: $familyName) | |
/// .disableAutocorrection(true) | |
/// } | |
/// .textFieldStyle(.roundedBorder) | |
/// } | |
/// ![Two vertically-stacked text fields, with the prompt text Given Name and | |
/// Family Name, both with rounded | |
/// borders.](SwiftUI-TextField-roundedBorderStyle.png) | |
/// | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
public struct TextField<Label> : View where Label : View { | |
/// The content and behavior of the view. | |
/// | |
/// When you implement a custom view, you must implement a computed | |
/// `body` property to provide the content for your view. Return a view | |
/// that's composed of primitive views that SwiftUI provides, plus other | |
/// composite views that you've already defined: | |
/// | |
/// struct MyView: View { | |
/// var body: some View { | |
/// Text("Hello, World!") | |
/// } | |
/// } | |
/// | |
/// For more information about composing views and a view hierarchy, | |
/// see <doc:Declaring-a-Custom-View>. | |
public var body: some View { get } | |
/// The type of view representing the body of this view. | |
/// | |
/// When you create a custom view, Swift infers this type from your | |
/// implementation of the required ``View/body-swift.property`` property. | |
public typealias Body = some View | |
} | |
extension TextField where Label == Text { | |
/// Creates a text field with a text label generated from a localized title | |
/// string. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title of the text field, | |
/// describing its purpose. | |
/// - text: The text to display and edit. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, prompt: Text? = nil) | |
/// Creates a text field with a text label generated from a title string. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text view, describing its purpose. | |
/// - text: The text to display and edit. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<S>(_ title: S, text: Binding<String>, prompt: Text? = nil) where S : StringProtocol | |
} | |
extension TextField { | |
/// Creates a text field with a prompt generated from a `Text`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - text: The text to display and edit. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
/// - label: A view that describes the purpose of the text field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init(text: Binding<String>, prompt: Text? = nil, @ViewBuilder label: () -> Label) | |
} | |
@available(iOS 13.0, macOS 10.15, tvOS 13.0, watchOS 6.0, *) | |
extension TextField where Label == Text { | |
/// Creates a text field with a text label generated from a localized title | |
/// string. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title of the text field, | |
/// describing its purpose. | |
/// - text: The text to display and edit. | |
/// - onEditingChanged: The action to perform when the user | |
/// begins editing `text` and after the user finishes editing `text`. | |
/// The closure receives a Boolean value that indicates the editing | |
/// status: `true` when the user begins editing, `false` when they | |
/// finish. | |
/// - onCommit: An action to perform when the user performs an action | |
/// (for example, when the user presses the Return key) while the text | |
/// field has focus. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
public init(_ titleKey: LocalizedStringKey, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void = { _ in }, onCommit: @escaping () -> Void = {}) | |
/// Creates a text field with a text label generated from a title string. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text view, describing its purpose. | |
/// - text: The text to display and edit. | |
/// - onEditingChanged: The action to perform when the user | |
/// begins editing `text` and after the user finishes editing `text`. | |
/// The closure receives a Boolean value that indicates the editing | |
/// status: `true` when the user begins editing, `false` when they | |
/// finish. | |
/// - onCommit: An action to perform when the user performs an action | |
/// (for example, when the user presses the Return key) while the text | |
/// field has focus. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:text:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
public init<S>(_ title: S, text: Binding<String>, onEditingChanged: @escaping (Bool) -> Void = { _ in }, onCommit: @escaping () -> Void = {}) where S : StringProtocol | |
} | |
extension TextField where Label == Text { | |
/// Create an instance which binds over an input to a format style, | |
/// `F.FormatInput`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - titleKey: The title of the text field, describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - format: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type | |
/// `F.FormatInput`. In the event that `format` is unable to perform | |
/// the conversion, `binding.value` is set to `nil`. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<F>(_ titleKey: LocalizedStringKey, value: Binding<F.FormatInput?>, format: F, prompt: Text? = nil) where F : ParseableFormatStyle, F.FormatOutput == String | |
/// Create an instance which binds over an input to a format style, | |
/// `F.FormatInput`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text field, describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - format: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type | |
/// `F.FormatInput`. In the event that `format` is unable to perform | |
/// the conversion, `binding.value` is set to `nil`. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<S, F>(_ title: S, value: Binding<F.FormatInput?>, format: F, prompt: Text? = nil) where S : StringProtocol, F : ParseableFormatStyle, F.FormatOutput == String | |
/// Create an instance which binds over an input to a format style, | |
/// `F.FormatInput`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text field, describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - format: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type | |
/// `F.FormatInput`. In the event that `format` is unable to perform | |
/// the conversion, `binding.value` is not updated. If the user | |
/// stops editing the text in an invalid state, the text field will | |
/// update the field's text to the last known valid value. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<F>(_ titleKey: LocalizedStringKey, value: Binding<F.FormatInput>, format: F, prompt: Text? = nil) where F : ParseableFormatStyle, F.FormatOutput == String | |
/// Create an instance which binds over an input to a format style, | |
/// `F.FormatInput`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text field, describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - format: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type | |
/// `F.FormatInput`. In the event that `format` is unable to perform | |
/// the conversion, `binding.value` is not updated. If the user | |
/// stops editing the text in an invalid state, the text field will | |
/// update the field's text to the last known valid value. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<S, F>(_ title: S, value: Binding<F.FormatInput>, format: F, prompt: Text? = nil) where S : StringProtocol, F : ParseableFormatStyle, F.FormatOutput == String | |
} | |
extension TextField { | |
/// Create an instance which binds over an input to a format style, | |
/// `F.FormatInput`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - value: The underlying value to be edited. | |
/// - format: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type | |
/// `F.FormatInput`. In the event that `format` is unable to perform | |
/// the conversion, `binding.value` is set to `nil`. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
/// - label: The label of the text field, describing its purpose. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<F>(value: Binding<F.FormatInput?>, format: F, prompt: Text? = nil, @ViewBuilder label: () -> Label) where F : ParseableFormatStyle, F.FormatOutput == String | |
/// Create an instance which binds over an input to a format style, | |
/// `F.FormatInput`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - value: The underlying value to be edited. | |
/// - format: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type | |
/// `F.FormatInput`. In the event that `formatter` is unable to perform | |
/// the conversion, `binding.value` is not updated. If the user | |
/// stops editing the text in an invalid state, the text field will | |
/// update the field's text to the last known valid value. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
/// - label: The label of the text field, describing its purpose. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<F>(value: Binding<F.FormatInput>, format: F, prompt: Text? = nil, @ViewBuilder label: () -> Label) where F : ParseableFormatStyle, F.FormatOutput == String | |
} | |
extension TextField where Label == Text { | |
/// Create an instance which binds over an arbitrary type, `T`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title of the text field, | |
/// describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - formatter: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type `T`. | |
/// In the event that `formatter` is unable to perform the conversion, | |
/// `binding.value` isn't modified. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<T>(_ titleKey: LocalizedStringKey, value: Binding<T>, formatter: Formatter, prompt: Text? = nil) | |
/// Create an instance which binds over an arbitrary type, `T`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text field, describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - formatter: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type `T`. | |
/// In the event that `formatter` is unable to perform the conversion, | |
/// `binding.value` isn't modified. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<S, T>(_ title: S, value: Binding<T>, formatter: Formatter, prompt: Text? = nil) where S : StringProtocol | |
} | |
extension TextField { | |
/// Create an instance which binds over an arbitrary type, `T`. | |
/// | |
/// You can associate an action to be invoked upon submission of this | |
/// text field by using an `View.onSubmit(of:_)` modifier. | |
/// | |
/// - Parameters: | |
/// - value: The underlying value to be edited. | |
/// - formatter: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type `T`. | |
/// In the event that `formatter` is unable to perform the conversion, | |
/// `binding.value` isn't modified. | |
/// - prompt: A `Text` representing the prompt of the text field | |
/// which provides users with guidance on what to type into the text | |
/// field. | |
/// - label: A view that describes the purpose of the text field. | |
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | |
public init<T>(value: Binding<T>, formatter: Formatter, prompt: Text? = nil, @ViewBuilder label: () -> Label) | |
} | |
extension TextField where Label == Text { | |
/// Create an instance which binds over an arbitrary type, `T`. | |
/// | |
/// - Parameters: | |
/// - titleKey: The key for the localized title of the text field, | |
/// describing its purpose. | |
/// - value: The underlying value to be edited. | |
/// - formatter: A formatter to use when converting between the | |
/// string the user edits and the underlying value of type `T`. | |
/// In the event that `formatter` is unable to perform the conversion, | |
/// `binding.value` isn't modified. | |
/// - onEditingChanged: The action to perform when the user | |
/// begins editing `text` and after the user finishes editing `text`. | |
/// The closure receives a Boolean value that indicates the editing | |
/// status: `true` when the user begins editing, `false` when they | |
/// finish. | |
/// - onCommit: An action to perform when the user performs an action | |
/// (for example, when the user presses the Return key) while the text | |
/// field has focus. | |
@available(iOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(macOS, introduced: 10.15, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(tvOS, introduced: 13.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
@available(watchOS, introduced: 6.0, deprecated: 100000.0, message: "Renamed TextField.init(_:value:formatter:onEditingChanged:). Use View.onSubmit(of:_:) for functionality previously provided by the onCommit parameter. Use FocusState<T> and View.focused(_:equals:) for functionality previously provided by the onEditingChanged parameter.") | |
public init<T>(_ titleKey: LocalizedStringKey, value: Binding<T>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void = { _ in }, onCommit: @escaping () -> Void = {}) | |
/// Create an instance which binds over an arbitrary type, `T`. | |
/// | |
/// - Parameters: | |
/// - title: The title of the text field, describing its purpose. | |
// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment