I want when the user enters a UITextField
field, make a simple animation of moving a UIView
down, for example.
If I put my Up Inside routine it works, the same routine in didBegin
of UItextfield
does not work, it animates down and when it arrives at the set point it returns to the place of departure.
PS: I use the same routine in both cases.
Does anyone have any idea what might be wrong?
Routine:
-(IBAction)testa:(id)sender {
CGPoint fromPt = self.viewStatus.layer.position;
CGPoint toPt = CGPointMake(fromPt.x, fromPt.y+200);
CABasicAnimation* anime = [CABasicAnimation animationWithKeyPath:@"position"];
anime.delegate = self;
anime.removedOnCompletion = NO;
anime.duration = 2;
anime.fromValue = [NSValue valueWithCGPoint:fromPt];
anime.toValue = [NSValue valueWithCGPoint:toPt];
CAMediaTimingFunction* tf = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseOut];
anime.timingFunction = tf;
[self.viewStatus.layer addAnimation:anime forKey:@"ResizeForKeyboard"];
self.viewStatus.frame = CGRectMake(self.viewStatus.frame.origin.x,
toPt.y,
self.viewStatus.frame.size.width,
self.viewStatus.frame.size.height);
}