I am new to SwiftUI.... View is a protocol which only contains required stored property called "body". My question is , where modifier methods come from. 'cause "Protocol methods must not have bodies".?
1 Answer
My question is , where modifier methods come from. 'cause "Protocol methods must not have bodies".?
From extension like in below example:
extension View {
    @ViewBuilder
    public func isHidden(_ hidden: Bool) -> some View {
        if hidden {
            self.hidden()
        }
        else {
            self
        }
    }
}
1 Comment
YodagamaHeshan
 is this the only way we can add method implementation to protocol ? could you please mention a resource link which I can find more details about this ? it will we help me to learn "how to learn" new things.
  
