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 trialWilliam Flynn
2,304 PointsTrying to add a press state
Really wanting to darken the tiles on touch down but can't for the life of me find anything online about how to do it. Note: I've found a bunch of stuff that helps but everyone on Stack Overflow does everything programmatically, not through storyboards, so it doesn't totally translate (at least for a noob like me).
Any help here?
William Flynn
2,304 PointsHey Aaron – it's a UIImage with a Tap Gesture Recognizer on it. Can't seem to find a way to capture touch down. Thanks!
1 Answer
agreatdaytocode
24,757 PointsTry this:
//Create the TapGesture
let singleTap = UITapGestureRecognizer(target: self, action: Selector("tapped"))
singleTap.numberOfTapsRequired = 1
//Setting the TapGesture to the UILabelView
yourLabelNameHere.addGestureRecognizer(singleTap)
yourLabelNameHere.userInteractionEnabled = true
//Creating a function to change the color of the UILabel on Tap.
func tapped() {
println("Game Started")
yourLabelNameHere.backgroundColor = UIColor(hex: "F0972C")
}
agreatdaytocode
24,757 Pointsagreatdaytocode
24,757 PointsWhat type of tile is it? UIView or UIImageView? If you can share some code I maybe able to help you.