Вопрос

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?

Это было полезно?

Решение

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;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top