zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    [转 scrum] Scrum的三个物件
    [转 scrum] 敏捷误解之无计划
    [转 scrum] Scrum三个角色及其职责介绍
    [转 scrum] Scrum的三个物件
    [转 scrum] Scrum三个角色及其职责介绍
    [转 scrum] Scrum术语字典
    浅尝异步IO
    LINUX内核内存屏障
    在C/C++程序里打印调用栈信息
    Ubuntu10.04下Linux内核编译的完整步骤
  • 原文地址:https://www.cnblogs.com/110-913-1025/p/9088134.html
Copyright © 2011-2022 走看看