Reputation: 554
I have a play button on my game and when i touch it i would like the image opacity to change or something just so that the user knows they have touched it.
Must be easy for somebody that knows how!
Upvotes: 1
Views: 7204
Reputation: 508
You can animate the button opacity inside the function which is executed when the button is pressed,
UIView.animate(withDuration: 0.2) {
sender.alpha = 0.5
}
UIView.animate(withDuration: 0.2) {
sender.alpha = 1
}
where sender refers to the UIButton.
Upvotes: 0
Reputation: 1449
The easiest way to change opacity in is to use the UIView
alpha
property like so:
yourView.alpha = 0.5 // 50% opacity
yourView.alpha = 0 // 0% opacity - completely transparent
yourView.alpha = 1 // 100% opacity - completely opaque
Upvotes: 3