iOS 动画

  • 移动动画
[UIView animateWithDuration:1.0f animations:^{
        CGFloat x = weakSelf.aniView.frame.origin.x + 200.0f;
        CGFloat y = weakSelf.aniView.frame.origin.y + 200.0f;
        weakSelf.aniView.frame = CGRectMake(x, y, 50.0f, 50.0f);
    }];
[UIView animateWithDuration:1.0f animations:^{
        CGFloat x = weakSelf.aniView.frame.origin.x + 200.0f;
        weakSelf.aniView.frame = CGRectMake(x, weakSelf.aniView.frame.origin.y, 50.0f, 50.0f);
    }];
    
    [UIView animateWithDuration:1.0f delay:1.0f options:UIViewAnimationOptionLayoutSubviews animations:^{
        CGFloat y = weakSelf.aniView.frame.origin.y + 200.0f;
        weakSelf.aniView.frame = CGRectMake(weakSelf.aniView.frame.origin.x, y, 50.0f, 50.0f);
    } completion:NULL];
  • 渐隐
[UIView animateWithDuration:1.0f animations:^{
        weakSelf.aniView.alpha = 0.0f;
}];
  • 缩放
[UIView animateWithDuration:1.0f animations:^{
        weakSelf.aniView.transform = CGAffineTransformScale(weakSelf.aniView.transform, 2.0f, 2.0f);
//        weakSelf.aniView.transform = CGAffineTransformMakeScale(1.5f, 1.5f);
    }];
  • 翻转
[UIView animateWithDuration:1.0f animations:^{
        weakSelf.aniView.transform = CGAffineTransformMakeRotation(M_PI / 2);
    }];
  • 重复动画
[UIView animateWithDuration:1.5f delay:0.0f options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAutoreverse animations:^{
        
        weakSelf.aniView.center = CGPointMake(20.0f, 50.0f);
        
    } completion:NULL];

你可能感兴趣的:(iOS 动画)