Generic Structure

StaticMember

A concrete wrapper for enabling implicit member expressions.

Declaration

struct StaticMember<Base>

Overview

Use StaticMember to support implicit member expressions, sometimes referred to as leading dot syntax, where they would normally not be supported, like static properties representing concrete values provided to a protocol-constrained generic function.

For example:

protocol ColorStyle {
    typealias Member = StaticMember<Self>
}

extension StaticMember where Base : ColorStyle {
    static var red: RedStyle.Member { return .init(.init()) }
    static var blue: BlueStyle.Member { return .init(.init()) }
}

extension View {
    func colorStyle<S : ColorStyle>(_ style: S.Member) -> some View {
        ...
    }
}

MyView().colorStyle(.red)
MyView().colorStyle(.blue)

Topics

Text Field Styles

static var plain: PlainTextFieldStyle.Member

A text field style with no decoration.

static var roundedBorder: RoundedBorderTextFieldStyle.Member

A text field style with a system-defined rounded border.

static var squareBorder: SquareBorderTextFieldStyle.Member

A text field style with a system-defined square border.

List Styles

static var `default`: DefaultListStyle.Member

The default list style.

static var plain: PlainListStyle.Member

A list style that implements the system default list interaction and appearance.

static var grouped: GroupedListStyle.Member

A list style that implements the system default grouped list interaction and appearance.

static var carousel: CarouselListStyle.Member

A list style that implements the carousel list interaction and appearance.

static var sidebar: SidebarListStyle.Member

A list style that implements the system default sidebar list (or source list) interaction and appearance.

Toggle Styles

static var `default`: DefaultToggleStyle.Member

The default toggle style.

static var `switch`: SwitchToggleStyle.Member

A toggle style represented by a trailing switch.

Picker Styles

static var `default`: DefaultPickerStyle.Member

The default picker style.

static var radioGroup: RadioGroupPickerStyle.Member

A picker style where each option is represented as a radio button.

static var popUpButton: PopUpButtonPickerStyle.Member

A picker style where the options are disclosed from a button that presents them in a menu.

static var wheel: WheelPickerStyle.Member

A picker style where the options are contained in a scrollable wheel.

Date Picker Styles

static var `default`: DefaultDatePickerStyle.Member

The default date picker style.

static var graphical: GraphicalDatePickerStyle.Member

A system style of date picker that displays an interactive calendar or clock.

static var field: FieldDatePickerStyle.Member

A system style that displays the components in an editable field.

static var stepperField: StepperFieldDatePickerStyle.Member

A system style that displays the components in an editable field, with adjoining stepper that can increment/decrement the selected component.

Pull Down Button Styles

static var prominent: _ProminentPullDownButtonStyle.Member
static var plain: _PlainPullDownButtonStyle.Member
static func plain(showArrows: Bool) -> _PlainPullDownButtonStyle.Member

Menu Button Styles

static var `default`: DefaultMenuButtonStyle.Member
static var pullDown: ProminentPullDownMenuButtonStyle.Member
static var borderlessButton: BorderlessButtonMenuButtonStyle.Member
static var borderlessPullDown: BorderlessPullDownMenuButtonStyle.Member

Button Styles

static var `default`: DefaultButtonStyle.Member

The default button style.

static var plain: PlainButtonStyle.Member
static var link: LinkButtonStyle.Member
static var bordered: BorderedButtonStyle.Member
static var borderless: BorderlessButtonStyle.Member

Navigation View Styles

static var `default`: DefaultNavigationViewStyle.Member
static var stack: StackNavigationViewStyle.Member
static var doubleColumn: DoubleColumnNavigationViewStyle.Member

Shape Styles

static var separator: SeparatorShapeStyle.Member

A style appropriate for foreground separator or border lines.

static func selection(Bool) -> SelectionShapeStyle.Member

Generates a style usable as the background for selected elements.

Creating a Static Member

init(Base)

Creates a static member representing the specified base.

See Also

Supporting Types

struct ViewBuilder

A custom parameter attribute that constructs views from closures.

Beta
protocol ViewModifier

A modifier that you apply to a view or another view modifier, producing a different version of the original value.

Beta
struct IdentifierValuePair

An identifier and its corresponding value.

Beta
struct IdentifierValuePairs

A collection of identifier-value pairs computed on demand.

Beta
struct NavigationButton

A button that triggers a navigation presentation when pressed.

Deprecated

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software