【问题标题】:Change the Alpha value of the touched portion on the UIImage?更改 UIImage 上触摸部分的 Alpha 值?
【发布时间】:2013-09-20 07:27:29
【问题描述】:

如何将 UIImage 的 alpha 值更改为零,当我触摸它时,我只需要更改 UIImage 触摸部分的 alpha 值。

谁能帮帮我?

【问题讨论】:

  • 看看我的回答......

标签: iphone ios ios5 ios6 ios6.1


【解决方案1】:

你可以使用 UITapGestureRecognizer 添加到 UIImageView。首先你需要将 delaget 添加到 .h UIGestureRecognizerDelaget .h 文件中。

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

您还需要 UserInterActionEnable 为 yes,默认为 no。

在这里做你想做的事

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

【讨论】:

  • 感谢您的回复。
【解决方案2】:

按照这些步骤操作。

  1. ImageView UserInteractionEnable 应该是 yes。
  2. 在 ImageView 上应用点击手势。
  3. 在点击手势选择器中。将 ImageView.alpha 属性设为 0。

如果你想为它制作动画,你可以使用它。

[UIView animateWithDuration:4.0 animations:^{

    ImageView.alpha = 0.0;
}];

【讨论】:

  • 嗨,谢谢您的回复。但我只需要在触摸坐标处更改 alpha 值....
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-27
  • 2012-05-08
相关资源
最近更新 更多