Regarding view modifiers in chap 3.1

Perhaps I am misunderstanding something (quite possible). I know that one can define custom view modifiers, but was under the impression that one had to use the modifier keyword when defining one. In ViewExtension.swift, however, the northWestShadow and southEastShadow funcs make no use of the the modifier keyword and the book text doesn’t seem to make any reference to using that keyword when declaring a custom modifier.
The only thing I can think of is that prefacing a view extension func name with a dot is shorthand for calling a func by that name that is defined by the View protocol.
Am I correct in assuming that a modifier defined within a view protocol extension doesn’t require the use of the modifier keyword, while one that is defined in a struct does? If so, it would help to clarify this in section 3.1 of the book.
Tom

hi Tom! I didn’t know about ViewModifier. The resources I found for neumorphism just used extension View, so that’s how I did mine.

Chapter 6 covers ViewModifier. He creates a ViewModifier structure, then puts the ModifiedContent call in a view extension.

Ignore my question, Audrey. I realized later on that my speculation in the question was, in fact, correct (helps to go to bed and stare at the ceiling for a while). Regarding the ViewModifier protocol and defining custom modifiers, I’ll explore it more when I get to Chapter 6. I may be premature in saying this, but I think adding view modifiers in an extension is a more elegant approach.
Tom

1 Like