Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [redSquare setCenter:CGPointMake(25,25)];
- -(void)moving{
- [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- int randomx = arc4random() % 295;
- [redSquare setCenter:CGPointMake(randomx,435)];
- } completion:^(BOOL finished) {
- [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
- }];
- }
- completion:^(BOOL finished) {
- [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- int randomx = arc4random() % 295;
- [redSquare setCenter:CGPointMake(randomx,25)];
- } completion:^(BOOL finished) {
- }];
- }];
- -(void)moving {
- [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- int randomx = arc4random() % 295;
- [redSquare setCenter:CGPointMake(randomx,435)];
- } completion:^(BOOL finished) {
- [UIViewAnimateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
- } completion: NULL
- }];
- }
- -(void)moving {
- workBlk_t animationBlock = ^ {
- int randomx = arc4random() % 295;
- [redSquare setCenter:CGPointMake(randomx,435)];
- };
- void (^completionBlock)(BOOL finished) = ^{
- [UIViewAnimateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
- } completion : NULL
- };
- [UIView animateWithDuration:1.0
- delay:0.0
- options:UIViewAnimationCurveEaseIn
- animations:animationBlock
- completion:completionBlock
- }];
- }
- completion:^(BOOL finished) {
- [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
- }
- -(void) moveDown{
- [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- int randomx = arc4random() % 295;
- [redSquare setCenter:CGPointMake(randomx,435)];
- } completion:^(BOOL finished) {
- // First animation completed
- [self moveBack];
- }];
- }
- -(void) moveBack{
- [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
- [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
- } completion:^(BOOL finished) {
- // Second animation completed
- }];
- }
Add Comment
Please, Sign In to add comment