Chapter 7: Drawing with SwiftUI
One of the strongest points of SwiftUI is that all the components are uniform and that 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 learn 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 learn how simple and natural it is to deal with, extend, and use custom shapes with standard components such as text and sliders.
By the end of the chapter, you'll be able to create a view from a custom path, add a gradient to fill a custom view, and will know how to write a Tic-Tac-Toe game using basic shapes.
In this chapter, we will cover the following recipes:
- Using SwiftUI's built-in shapes
- Drawing a custom shape
- Drawing a curved custom shape
- Drawing using the Canvas API
- Implementing a progress ring
- Implementing a Tic-Tac-Toe...