UITapGestureRecognizer recognizing tap after scaling UIView
- by Bikash Mishra
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.