希望通过点击手势更改UIimageview alpha,例如:
点按 - 将alpha更改为0.5f
再次点按 - alpha返回1状态
有可能吗?
答案 0 :(得分:6)
是
将点按手势识别器附加到视图:
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourFunction:)];
[imageView addGestureRecognizer:tap];
然后在手势识别器的处理程序中:
if (imageView.alpha > 0.5f){
imageView.alpha = 0.5f;
}
else {
imageView.alpha = 1.0;
}