|
Hi, I'm currently working on project 9 part 3. The code below produces a checkerboard with black and white squares. However it can't work out how?
Thanks, Ed |
|
Hi Ed, What can you not work out! I assume you have the rest of the code in the tutorial Animating complex shapes with AnimatablePair
then you can use it your view
|
|
Hey Ed, The way nested
So when A loop operates on the principle that ALL code within it has to complete before it moves to the next iteration. So in the project, we are essentially drawing 1 row at a time. until we have the desired amount. As for startX, you are basically on the horizontal axis. So you account for the width of each column. And that gives the initial x point for each square. startY is on the vertical axis, so we account for the width of each row. which gives us the initial y point for each square. |
|
Hi all, thank you for responding! I understand the nested look, what i don't understand is which bit of code causes the squares to be either black or white? |
|
Hi @tillsonej .... this is it right here:
So every other square gets the rectangle drawn, and is colored. Where no rectangle is drawn, there is just whitespace. Make sense? |
SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.