Chapter 6: Drawing with SwiftUI

One of the strongest points of SwiftUI is that all the components are uniform, and they can be used in an interchangeable and mixed way, whereas in UIKit, intermixing labels, buttons, and custom shapes was a bit cumbersome. In this chapter, we'll see how to use the basic shapes offered out of the box by SwiftUI and how to create new shapes using the Path class. We'll see how simple and natural it is to deal with, extend, and use them with standard components such as text and sliders.

At the end of the chapter, you'll be able to create a view from a custom path, add a gradient to fill it or to act as a border, and will know how to write a Tic-Tac-Toe game using basic shapes.

In this chapter, we will cover the following ...

Get SwiftUI Cookbook 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.