For some reason I have to use a customized UIView
which contains several UIImageView
s in it to act as a button. (I cannot use a button instead, since the imageViews have independent dynamic contents)
I want them(all the imageViews in my customized UIView
) to be dimmed when the touch begins then back to normal when the touch ends.
I plan to use a UITapGestureRecognizer
to implement this. So in my customized UIView
, I have a tapGestureRecognizer. My code looks like this:
- (void)costomizedViewTapped:(UITapGestureRecognizer *)tapRecognizer {
if (tapRecognizer.state == UIGestureRecognizerStateBegan) {
// dim all my imageViews
NSLog(@"dimmed");
}
if (tapRecognizer.state == UIGestureRecognizerStateCancelled ||
tapRecognizer.state == UIGestureRecognizerStateEnded ||
tapRecognizer.state == UIGestureRecognizerStateFailed) {
// make all my imageViews back to normal
NSLog(@"normaled");
if (tapRecognizer.state == UIGestureRecognizerStateEnded) {
// do something to handle the tap
}
}
}
My simple silly question is that how can I dim the imageViews to make them appear like a button being pressed?
Also, I found that my code can only log out the message normaled
for each tap, but I want it to be able to log out dimmed
when the tap begins, how can I modify my code to do that?