iOS 帧动画之翻转和旋转动画

记录两个比较简单的动画,一个是翻转的动画,一个是旋转的动画。

旋转动画:

[UIView animateWithDuration:3 animations:^{
        if (formView) {
            formView.transform = CGAffineTransformMakeRotation(M_PI);
        }
    }];

2

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    //默认是顺时针效果,若将fromValue和toValue的值互换,则为逆时针效果
    animation.fromValue = [NSNumber numberWithFloat:0.f];
    animation.toValue = [NSNumber numberWithFloat: M_PI *2];
    animation.duration = 3;
    animation.autoreverses = NO;
    animation.fillMode = kCAFillModeForwards;
    animation.repeatCount = MAXFLOAT; //如果这里想设置成一直自旋转,可以设置为MAXFLOAT,否则设置具体的数值则代表执行多少次
    [formView.layer addAnimation:animation forKey:nil];

 

 翻转动画:

1 围绕中间轴翻转

[UIView transitionWithView:formView duration:2.0f options:UIViewAnimationOptionTransitionFlipFromTop animations:^{
        
        
    } completion:^(BOOL finished) {
        NSLog(@"图像翻转完成");
    }];

 2 翻页,类似日历的那种

//开始动画
    [UIView beginAnimations:@"doflip" context:nil];
    //设置时常
    [UIView setAnimationDuration:1];
    //设置动画淡入淡出
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    //设置代理
    [UIView setAnimationDelegate:self];
    //设置翻转方向
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:formView cache:YES];
    //动画结束
    [UIView commitAnimations];

 3 翻页 往上翻

 [UIView beginAnimations:@"curlUp" context:nil];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];//指定动画曲线类型,该枚举是默认的,线性的是匀速的
    //设置动画时常
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    //设置翻页的方向
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:formView cache:YES];
    //关闭动画
    [UIView commitAnimations];

 4 缩放动画,直接在原来的基础上进行缩放

    CGAffineTransform transform;
    transform = CGAffineTransformScale(formView.transform,1.2,1.2);
    [UIView beginAnimations:@"scale" context:nil];
    [UIView setAnimationDuration:2];
    [UIView setAnimationDelegate:self];
    [formView setTransform:transform];
    [UIView commitAnimations];

 5

转载于:https://www.cnblogs.com/110-913-1025/p/9088134.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值