Question

Wish to change UIimageview alpha with tap gesture, for example:

Tap - change alpha to 0.5f
Tap again - alpha back to 1 state

Is it possible?

Was it helpful?

Solution

Yes.

Attach a tap gesture recognizer to the view:

UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourFunction:)];
[imageView addGestureRecognizer:tap];

then in the gesture recognizer's handler:

if (imageView.alpha > 0.5f){
    imageView.alpha = 0.5f;
}
else {
    imageView.alpha = 1.0;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top