I want to implement a delayed 'enlarging' animation on an UIView that is being dragged using an attached UIPanGestureRecognizer. I've been using something similar to the following code:
UIView* innerView;
CGPoint startingPoint;
- (void)viewDidLoad {
innerView = [[[UIView alloc] autorelease] initWithFrame:CGRectMake(0, 0, 200, 200)];
[[self view] addSubview:innerView];
[innerView setBackgroundColor:[UIColor blueColor]];
[innerView addGestureRecognizer:[[[UIPanGestureRecognizer alloc] autorelease] initWithTarget:self action:@selector(pan:)]];
// resize it later
[self performSelector:@selector(anim) withObject:nil afterDelay:1.5];
}
-(void)pan:(UIPanGestureRecognizer*)gr {
CGPoint gesturePoint = [gr translationInView:[self view]];
if (gr.state == UIGestureRecognizerStateBegan)
startingPoint = innerView.center;
else
innerView.center = CGPointMake(startingPoint.x + gesturePoint.x, startingPoint.y +gesturePoint.y);
}
-(void)anim{
innerView.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1);
}
But the view 'jumps' when being dragged after the scale is applied. This behavior doesnt happen always, but in pseudo-random manner. Any one can shed light on this issue or propose a different approach?