Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Mark Cranston
1,817 PointsRandomly create rectangles
I want to add a background to my app that consists of falling squares. What is the best way to go about this? That squares must continuously spawn at the top of the screen, then slowly fall and disappear at the bottom. I am currently trying to to use the CGRect Command, but nothing is appearing in my simulator. Thanks in advance!
'''swift var rectangle = CGRect(x:0, y:0, width: 100, height: 100) '''
2 Answers
Gabe Nadel
Treehouse Guest TeacherIt looks like you are skipping the steps of creating CGContext adding the Rect to the context and filling the CGRect...
I'd read up on those items to see where they fit in.
If you'd like some sample code to get you up and running, here is a good example - it has more than you need, but includes a solution to your problem...
Gabe Nadel
Treehouse Guest TeacherThe community is always happy to help, but it's tough without seeing your code.
If you post it in here, I'm sure you'll get some useful feedback....
Thanks for updating your initial question with the code, that makes all the difference!