【发布时间】:2013-05-06 21:40:04
【问题描述】:
希望通过点击手势更改 UIimageview alpha,例如:
点击 - 将 alpha 更改为 0.5f
再次点击 - alpha 回到 1 状态
有可能吗?
【问题讨论】:
希望通过点击手势更改 UIimageview alpha,例如:
点击 - 将 alpha 更改为 0.5f
再次点击 - alpha 回到 1 状态
有可能吗?
【问题讨论】:
是的。
将点击手势识别器附加到视图:
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;
}
【讨论】:
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath。