From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Core graphics in SwiftUI

Core graphics in SwiftUI

- [Instructor] SwiftUI integrates CoreGraphics differently than UIkit. And you can see this clearly in drawing paths. Let's take a look at the basics of drawing paths in SwiftUI. For the exercise file, I've a simple SwiftUI project set up here. It's an array of points using a object DrawPoint that has an enum and our coordinates and I actually set that up separately over here and you can see how I did that. It's a struct with CGFloats and a pointType, which I have up here, which is that enum for draw and move. And then I put a computed property here to set it back up. Now, going back over to the ContentView, you'll see I've made a whole set of paths and I've set which ones are to move and which ones to draw. So this just makes our work a little easier further down. And what we'll use to do this, if I drop all the way down here in the body, is in my VStack, I'm going to put a path like this. And path has a…

Contents