【发布时间】:2013-09-20 07:27:29
【问题描述】:
如何将 UIImage 的 alpha 值更改为零,当我触摸它时,我只需要更改 UIImage 触摸部分的 alpha 值。
谁能帮帮我?
【问题讨论】:
-
看看我的回答......
标签: iphone ios ios5 ios6 ios6.1
如何将 UIImage 的 alpha 值更改为零,当我触摸它时,我只需要更改 UIImage 触摸部分的 alpha 值。
谁能帮帮我?
【问题讨论】:
标签: iphone ios ios5 ios6 ios6.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;
}];
}
【讨论】:
按照这些步骤操作。
如果你想为它制作动画,你可以使用它。
[UIView animateWithDuration:4.0 animations:^{
ImageView.alpha = 0.0;
}];
【讨论】: