
iOS 14 Programming for Beginners
By :

At present, the RestaurantDetailViewController
class has an outlet, ratingsView
, connected to a ratings view in the Restaurant Detail screen. It displays a rating of three and a half stars, but you can't change the rating. You will need to support touch events to make the ratings view respond to taps.
Important information
You can learn more about handling touches at https://developer.apple.com/documentation/uikit/touches_presses_and_gestures/handling_touches_in_your_view.
To support touch events, you'll modify the RatingsView
class to track the user's touches on screen and use them to determine the rating. Follow these steps:
RatingsView.swift
in the Project navigator and add the following after the draw(_:)
method:override var canBecomeFirstResponder: Bool{ return true }
canBecomeFirstResponder
is a UIControl
property that determines whether an object can become the first responder...