Your First iOS & SwiftUI App: Polishing the App, Episode 18: Challenge: Start Over | raywenderlich.com

Get some more coding practice by implementing the “Start Over” button in Bull’s Eye.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/28797859-your-first-ios-swiftui-app-polishing-the-app/lessons/18

Just curious, why not use the .onTapGesture on the RoundedImageViewStroked

            RoundedImageViewStroked(systemName: "arrow.counterclockwise")
                .onTapGesture {
                    game.restartGame()
                }

The built-in Button type offers a lot of functionality that won’t be present with a tap gesture on a view—even though that is definitely a component of what makes up Button. In the case of this app, the only meaningful difference I can think of is that Button will offer a visual tapped state.

1 Like

Thank you for the response! I found the .onTapGesture a super short clean way for code and after reading the Dev Documentation I can see other benefits when the design calls for it. Thanks @jessycatterwaul