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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.