Skip to main content

Day 46

About 2 minSwiftcrashcoursepaul-hudsonswiftswiftuihacking-with-swiftxcodeappstore

Day 46 ๊ด€๋ จ


Project 9, part 4

100 Days of SwiftUI - 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

100 Days of SwiftUI - Day 46 - Drawing: Wrap up

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.open in new window

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.

  1. 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.
  2. Make the line thickness of your Arrow shape animatable.
  3. Create a ColorCyclingRectangle shape that is the rectangular cousin of ColorCyclingCircle, 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.

:::


์ด์ฐฌํฌ (MarkiiimarK)
Never Stop Learning.