iOS 8 animation bug

后端 未结 4 1622
日久生厌
日久生厌 2020-12-28 15:47

I have a simple method for animate view.

-(void)animateSelf
{
    CABasicAnimation * animation;

    animation = [CABasicAnimation animationWithKeyPath:@\"po         


        
4条回答
  •  囚心锁ツ
    2020-12-28 16:25

    This example might help you, I wish I had discovered it before wasting hours. Rather than animate the frame, animates its contraints. Click on the auto layout constraint you would like to adjust (in interface builder e.g top constraint). Next make this an IBOutlet;

    @property (strong, nonatomic) IBOutlet NSLayoutConstraint *topConstraint;
    

    Animate upwards;

    self.topConstraint.constant = -100;    
    [self.viewToAnimate setNeedsUpdateConstraints]; 
    [UIView animateWithDuration:1.5 animations:^{
        [self.viewToAnimate layoutIfNeeded]; 
    }];
    

    Animate back to original place

    self.topConstraint.constant = 0;    
    [self.viewToAnimate setNeedsUpdateConstraints];  
    [UIView animateWithDuration:1.5 animations:^{
        [self.viewToAnimate layoutIfNeeded];
    }];
    

    Originally posted by me here

    So you would adjust the constraint for self.view.frame in your example.

提交回复
热议问题