UITapGestureRecognizer recognizing tap after scaling UIView

Posted by Bikash Mishra on Stack Overflow See other posts from Stack Overflow or by Bikash Mishra
Published on 2012-04-10T05:07:02Z Indexed on 2012/04/10 5:28 UTC
Read the original article Hit count: 298

Filed under:
|

I have a UIView which I scale to 4x after tapping on it. It works fine. On the next tap I want to restore it back to original size. The problem is that it recognizes the tap only in the smaller rectangle the UIView had before scaling. I would like to recognize the tap anywhere in the scaled UIView. How can I achieve it?

//Tapping code
titleCard = [[UIView alloc] initWithFrame: myrect];
[self addSubview:titleCard];
[titleCard release];

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changeSize:)];
[tapRecognizer setNumberOfTouchesRequired:1];
[tapRecognizer setNumberOfTapsRequired:1];
[titleCard addGestureRecognizer:tapRecognizer];
[tapRecognizer release];

//Scaling code
CABasicAnimation *scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
[scale setBeginTime:CACurrentMediaTime()+0.75];
[scale setDuration:0.5];
[scale setToValue: [NSNumber numberWithFloat:4.0f]];
[scale setRemovedOnCompletion:NO];
[scale setFillMode:kCAFillModeForwards];

Thanks.

© Stack Overflow or respective owner

Related posts about ios

Related posts about uigesturerecognizer