swift โฉ custom โฉ snippets โฉ view modifier (template)
import SwiftUI // 1. (internal) view modifier struct MyViewModifier: ViewModifier { // โญ๏ธ 2. new states (optional) @State private var blur = true // body(content:) - ViewModifier requirement func body(content: Content) -> some View { // โญ๏ธ 3. modify input `content` content .blur(radius: blur ? 20 : 0) .clipped() .onTapGesture { withAnimation { self.blur.toggle() } } } } // โญ๏ธ 4. public helper extension View { public func myModifier() -> some View { modifier(MyViewModifier()) } }
view modifier
ViewModifier
.nsfw()
Last updated 2 months ago
Was this helpful?