Start of animation of a UIView x frame with a bounce effect

I managed to activate my UIView while moving its frame.origin.x from x to x-200; however, when frame.origin.x reaches x-200, I would like it to bounce back and forth a bit.

Are there any tips on how I should do this? thank

int targetX = 200;

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

myView.frame = CGRectMake(targetX, 0, [myView frame].size.width, [myView frame].size.height);
[UIView commitAnimations];
+3
source share
1 answer

I believe that you need to make an animation of the path. See http://www.bdunagan.com/2009/04/26/core-animation-on-the-iphone/ for a simple tutorial on this.

The main animation is just an animation between one point and another with some changes in speed (lightness, ease). An animation path can perform curves, changes in direction, etc.

+7
source

Source: https://habr.com/ru/post/1790298/


All Articles