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 trialAbdelGhafour Mohie
1,876 PointsTouch Event
What if i want to only touch the Crystal shape in order to excite my code ?! do i need to have that specific shape in a separate viewImage ?! How to accomplish that ?
1 Answer
Sam Soffes
Treehouse Guest TeacherYou could do this with UITapGestureRecognizer
. If you set the delegate, there's a method for gestureRecognizer:shouldReceiveTouch:
. You could use this to see if the point they touched is in the crystal shape. Knowing where the shape is is a bit tricky. I'd probably make a UIBezierPath
with a circle and a rectangle and then call containsPoint:
on it.
I bet this is a bit more complicated than you expected :) It's generally a good idea to make hit areas bigger than the actual object on iOS (especially for small things). You want to make it as easy as possible touch stuff. If there's nothing around something and a the users touches there, they probably meant to touch the button it's near.