Displaying ratings in our custom UIControl

Inside the RatingsView.swift file, we first need to create all of the variables we will need. Add the following under the class declaration:

let imgFilledStar = #imageLiteral(resourceName: "filled-star")let imgHalfStar = #imageLiteral(resourceName: "half-star")let imgEmptyStar = #imageLiteral(resourceName: "empty-star")let shouldBecomeFirstResponder = truevar rating:CGFloat = 0.0var totalStars = 5 

If you copy and paste this code, you will have to select each image to see the actual image. If you are having trouble using an image literal, you can use UIImage(named:) instead.

We are doing something new in this file. We are using image literals as our variables. If you type Image Literal in your ...

Get iOS 12 Programming for Beginners - Third 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.