문제

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