1
I want when the user enters a field UITextField
, make an animation simple to move a UIView
down, for example.
If I put my Up Inside routine works, the same routine in didBegin
of UItextfield
doesn’t work, it animates down and when it reaches the set point it goes back to the starting place.
PS: 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);
}
shared a folder with the project I made to test. Just unzip the zip. https://www.dropbox.com/s/mj4ceg6v2uo7vaz/teste.zip?dl=0
– Moacir Lamego