Adding support for touch events

Currently, RestaurantDetailViewController has an outlet, ratingView connected to a ratings view object in the Restaurant Detail screen. It displays a rating of 3.5 stars, but you can't change the rating. To make ratings view respond when touched so that the user can change the rating, you will need to support touch events.

Perform the following steps:

  1. Click RatingsView.swift in the Project navigator and add the following code after the draw(_:) method:
override var canBecomeFirstResponder: Bool{    return shouldBecomeFirstResponder}

canBecomeFirstResponder

Get iOS 13 Programming for Beginners - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.