Guest User

Untitled

a guest
Jan 21st, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. [redSquare setCenter:CGPointMake(25,25)];
  2.  
  3. -(void)moving{
  4.  
  5. [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  6. int randomx = arc4random() % 295;
  7. [redSquare setCenter:CGPointMake(randomx,435)];
  8.  
  9.  
  10. } completion:^(BOOL finished) {
  11.  
  12. [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
  13. }];
  14.  
  15. }
  16.  
  17. completion:^(BOOL finished) {
  18. [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  19. int randomx = arc4random() % 295;
  20. [redSquare setCenter:CGPointMake(randomx,25)];
  21.  
  22.  
  23. } completion:^(BOOL finished) {
  24.  
  25.  
  26. }];
  27. }];
  28.  
  29. -(void)moving {
  30.  
  31. [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  32. int randomx = arc4random() % 295;
  33. [redSquare setCenter:CGPointMake(randomx,435)];
  34. } completion:^(BOOL finished) {
  35. [UIViewAnimateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  36. [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
  37. } completion: NULL
  38. }];
  39.  
  40. }
  41.  
  42. -(void)moving {
  43.  
  44. workBlk_t animationBlock = ^ {
  45. int randomx = arc4random() % 295;
  46. [redSquare setCenter:CGPointMake(randomx,435)];
  47. };
  48.  
  49. void (^completionBlock)(BOOL finished) = ^{
  50. [UIViewAnimateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  51. [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
  52. } completion : NULL
  53. };
  54.  
  55. [UIView animateWithDuration:1.0
  56. delay:0.0
  57. options:UIViewAnimationCurveEaseIn
  58. animations:animationBlock
  59. completion:completionBlock
  60. }];
  61.  
  62. }
  63.  
  64. completion:^(BOOL finished) {
  65. [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
  66. }
  67.  
  68. -(void) moveDown{
  69. [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  70. int randomx = arc4random() % 295;
  71. [redSquare setCenter:CGPointMake(randomx,435)];
  72.  
  73. } completion:^(BOOL finished) {
  74. // First animation completed
  75. [self moveBack];
  76. }];
  77. }
  78.  
  79. -(void) moveBack{
  80. [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationCurveEaseIn animations:^{
  81. [redSquare setCenter:CGPointMake(redSquare.frame.origin.x,25)];
  82. } completion:^(BOOL finished) {
  83. // Second animation completed
  84. }];
  85. }
Add Comment
Please, Sign In to add comment