I am trying to create this modifier:
struct CustomTextBorder: ViewModifier {
func body(content: Content) -> some View {
return content
.font(.largeTitle)
.padding()
.overlay(
RoundedRectangle(cornerRadius: 15)
.stroke(lineWidth: 2)
)
.foregroundColor(.blue)
}
}
When I do, I get Type 'CustomTextBorder' does not conform to protocol 'ViewModifier'
error.
It seems like I have to add:
typealias Body = <#type#>
However, I see modifiers being created as I originally did here without having to provide the typealias Body...
This modifier works here:
https://www.simpleswiftguide.com/how-to-make-custom-view-modifiers-in-swiftui/
Why isn't it working for me?
How can I make this modifier work? Why does it work for some and not for others? Does it depend on what the project targets? I am targeting iOS 15.