concept draw in category ios

This is an excerpt from Manning's book iOS Development with Swift.
Up to now, all the visuals you’ve used in apps have been standard UIKit components or PNG images from the asset catalog. What if you want to go a little further and draw your own 2D shapes in code? Perhaps you want to draw a simple shape such as a rectangle or circle or a more complicated path such as a star or even a custom button. One way to achieve drawing in Swift is with the Core Graphics framework.
The most common place to draw using Core Graphics is in the draw method of UI-View. This method is called when a view is first laid out and any time that the view needs to be redrawn.
Create a subclass of UIView called Star. The draw method shows up in the UIView template, but it’s commented out. Uncomment the draw method: class Star: UIView { override func draw(_ rect: CGRect) { // Drawing code } }class Star: UIView { override func draw(_ rect: CGRect) { // Drawing code } }Note that the draw method is passed a rect parameter containing the dimensions available to you to draw in.