ViewModifier
protocol · iOS 13.0+ · SDK 27.1
@MainActor @preconcurrency protocol ViewModifierA modifier that you apply to a view or another view modifier, producing a different version of the original value. Adopt the ``ViewModifier`` protocol when you want to create a reusable modifier that you can apply to any view. The example below combines several modifiers to create a new modifier that you can use to create blue caption text surrounded by a rounded rectangle: struct BorderedCaption: ViewModifier { func body(content: Content) -> some View { content .font(.caption2) .padding(10) .overlay( RoundedRectangle(cornerRadius: 15) .stroke(lineWidth: 1) ) .foregroundColor(Color.blue) } } You can apply ``View/modifier(_:)`` directly to a view, but a more common and idiomatic approach uses ``View/modifier(_:)`` to define an extension to ``View`` itself that incorporates the view modifier: extension View { func borderedCaption() -> some View { modifier(BorderedCaption()) } } You can then apply the bordered caption to any view, similar to this: Image(systemName: "bus") .resizable() .frame(width:50, height:50) Text("Downtown Bus") .borderedCaption()  A type conforming to this protocol inherits `@preconcurrency @MainActor` isolation from the protocol if the conformance is included in the type's base declaration: struct MyCustomType: Transition { // `@preconcurrency @MainActor` isolation by default } Isolation to the main actor is the default, but it's not required. Declare the conformance in an extension to opt out of main actor isolation: extension MyCustomType: Transition { // `nonisolated` by default }
Members (0)
This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.
Skipped declarations
4 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.
ViewModifier.body(content:)
The iOS SDK compiler rejected this binding: cannot access type alias 'Content' from 'ViewModifier'; use a concrete type or generic parameter base instead
ViewModifier.concat(_:)
This protocol needs associated types that cannot yet cross the bridge.
ViewModifier.transaction(_:)
This protocol needs associated types that cannot yet cross the bridge.
ViewModifier.animation(_:)
This protocol needs associated types that cannot yet cross the bridge.