Day 46
Day 46 ๊ด๋ จ
Project 9, part 4
Thatโs another project finished, and at this point youโve had a taste of almost all of SwiftUIโs drawing APIs. Chances are you want to get back to building apps, but please take a moment to pause and review what youโve learned โ you might not use all of it for some time, but itโs important you at least remember what was covered so you can refer back to it later.
So, today you have another review to test what you remember, and also some challenges to get you coding yourself. As always these challenges donโt come with solutions by me, but thatโs the point โ as American NFL player Troy Polamalu once said, โIโve always had the mind-set that no one can challenge me better than myself.โ
You have free rein to solve them however you want and in whatever time you want, and you might sail through problem-free. On the other hand, perhaps in completing them youโll spot a few places where your knowledge was a bit shaky โ the only way youโll know is if you try.
Today you should work through the wrap up chapter for project 9, complete its review, then work through all three of its challenges.
Drawing: Wrap up
::: detatils Drawing: Wrap up
We covered a huge amount of ground in this project, and youโve learned about paths, shapes, strokes, transforms, drawing groups, animating values, and more. Not everyone will want to use all those features, and thatโs OK โ hopefully you have a clear idea of which parts interested you the most, and have some good coding experience with them.
If you combine your new-found drawing abilities with all the animation functionality we covered back in project 6, I hope youโre starting to realize just how much power and flexibility SwiftUI gives us. Yes, you can of course create whole apps using List
, NavigationView
, and similar, but you can also build completely custom user interfaces that look fantastic and are just as fast.
Review what you learned
Anyone can sit through a tutorial, but it takes actual work to remember what was taught. Itโs my job to make sure you take as much from these tutorials as possible, so Iโve prepared a short review to help you check your learning.
Click here to review what you learned in this project.
Challenge
One of the best ways to learn is to write your own code as often as possible, so here are three ways you should try extending this app to make sure you fully understand whatโs going on.
- Create an
Arrow
shape โ having it point straight up is fine. This could be a rectangle/triangle-style arrow, or perhaps three lines, or maybe something else depending on what kind of arrow you want to draw. - Make the line thickness of your
Arrow
shape animatable. - Create a
ColorCyclingRectangle
shape that is the rectangular cousin ofColorCyclingCircle
, allowing us to control the position of the gradient using one or more properties.
Tip: Gradient positions like .top
and .bottom
are actually instances of UnitPoint
, and you can create your own UnitPoint
instances with X/Y values ranging from 0 to 1.
:::
Drawing: Wrap up - Additional