2013-05-06 35 views
2

願望更改UIImageView的α波狀態改變的UIImageView阿爾法與點觸手勢,例如:自來水

點擊 - 改變阿爾法0.5F
再次點按 - 阿爾法回到1個狀態

這可能嗎?

回答

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; 
} 
+0

是的,謝謝你,它可以幫助:) – 2013-05-06 22:08:45

+0

我想知道,你在更改UITableViewCell中imageView的alpha值後需要調用' - (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath'。 – BlackMamba 2014-05-19 01:10:41