Meta- iOS Developer Professional Certificate Overview In this exercise, you will practice working with gestures. You will build a simple app that upgrades a variable when a gesture is activated.
Imagine the Little Lemon restaurant would like to create a reusable button in the app's UI that changes color every time a user taps on it, to indicate that it was selected by the user. This is a functionality that is common in iOS applications and is something you'll work on in this exercise.
Create a new project in Xcode to complete this exercise. Once you have created a new project, follow the steps below to create a new view called GestureRecognizer.
The goal of this exercise is to create a view that one can tap on and whose background color will change as a result of the tap.
Task 1: Create a rounded rectangle button Step 1: With ContentView selected on Project Navigator, select File > New > File.
Step 2: Choose Select SwiftUI View under User Interface and select Next.
Step 3: Name it GestureRecognizer and click Next.
Step 4: A new view called GestureRecognizer will be created on a different file and added to the project.
Step 5: Create a Boolean variable called flag that is initially false in GestureRecognizer.
Step 6: Create a Text element displaying the string Tap Me. This Text element should be white, use the large title font size, and have a padding of 15 points.
Step 7: This Text element background color should be green if flag is true and yellow otherwise.
Hint: You will need a Boolean variable of some sort to accomplish this task.
Task 2: Add a tap gesture method Step 1: add a gesture to the Text element that allows you to toggle between the different color states your view uses.