From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Draw paths in UIViews

Draw paths in UIViews

- [Instructor] In a previous tip, I drew rectangles and circles in a UI view. This time let's add lines and curves using paths, to draw some toast. Download the playground I set up for you. Check on that earlier lesson to learn what I did here with the image renderer and the image right here, and this addSubView down here. That will give you more information about that. We're going to go put stuff right here in the place drawing code here. And you'll notice I put some editable code tags here, if you're doing this on iPad playgrounds, to make it very simple to figure out where you need to go. Before you draw, you should set up a few properties. Start with the color. For the fill color of our toast, I'm going to add brown. So I'm going to do UIColor.brown. And I'm going to use setFill to set it as a fill. And then I'm going to set the stroke to purple, because it's just a nice contrasting color. And I'm going to do UIColor.purple.setStroke. And that'll set the outline for my toast to…

Contents