I get an error "Type 'PlayButtonModifier' does not conform to protocol 'ViewModifier'
" and I do not understand why and - even more important - how to do it right.
I simply try to create a ViewModifier
for an Image
, so that I can use for example .resizable()
on it, which is only defined in Image
In the ViewModifier
protocol, there's an Typealias
for Content
defined. My naiv thinking was that this should work:
struct PlayButtonModifier: ViewModifier {
typealias Content = Image
func body(content: Content) -> some View {
content
}
}
Well, no. Too easy. Same thing happens with implicit type alias for structs:
struct PlayButtonModifier: ViewModifier {
func body(content: Image) -> some View {
content
}
}
Same error.
What is wrong here? How would it be correct?