Вопрос

How can I change the alpha value of the UIImage to zero , when I touched on it, I need to change the alpha value of the touched portion of UIImage only.

Who can help me?

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

Решение

you can use UITapGestureRecognizer added to the UIImageView. First you Need to add delaget to .h UIGestureRecognizerDelaget .h file.

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(imageTaped:)];
singleTap.numberOfTapsRequired = 1;
[self.imageview addGestureRecognizer:singleTap];

you also need to UserInterActionEnable to yes by default it is no.

and do what you want here

- (void)imageTaped:(UIGestureRecognizer *)gestureRecognizer 
{
    [UIView animateWithDuration:0.5 animations:^(void)
    {
         imageView.alpha = 0.0;
    }];
}

Другие советы

Follow these steps.

  1. ImageView UserInteractionEnable should be yes.
  2. Apply tap gesture on ImageView.
  3. In tapGesture selector. Make the ImageView.alpha property to 0.

if you want to animate it you can use this.

[UIView animateWithDuration:4.0 animations:^{

    ImageView.alpha = 0.0;
}];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top