Launching animation of the UIView movement during the course of another one without completion?


  • QA Engineer

    There's animation:

    [UIView animateWithDuration:2 animations:^{
        self.imageView.center = point;
    }];
    

    We need to start the same thing, only with a new point, so the image View moves straight. If there is nothing to say, the picture is moving on the arc first towards the point of first animation, and then it starts moving to point point of second animation. I've got to take this oak away. If you remove the first animation, the wool jumps to the end and starts moving from there. UIViewAnimationOptionBeginFromCurrentState , unfortunately, does not help =(



  • This is an option: when the second anaemia is to be launched, watch the location of the object through the layer, remove the animation, put the object in the current position and launch the second analogy.

    That's how to find out the current position of the animated object.

    CGRect current = [[self.aView.layer presentationLayer] frame];
    

    That's how it works.

    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    
    self.aView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    self.aView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:self.aView];
    
    [UIView animateWithDuration:5 animations:^{
        self.aView.center = CGPointMake(325, 50);
    }];
    [self performSelector:@selector(shift) withObject:nil afterDelay:2];
    

    }

    • (void)shift {

      CGRect current = [[self.aView.layer presentationLayer] frame];
      [self.aView.layer removeAllAnimations];
      self.aView.frame = current;
      [UIView animateWithDuration:3 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
      self.aView.center = CGPointMake(150, 300);
      } completion:^(BOOL finished) {

      }];
      }


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2