• 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

  • 相关阅读:
    java垃圾回收机制
    mysql的find_in_set函数操作
    mysql中常见的sql语句语法书写操作
    如何破坏双亲委派原则
    mysql中临时表的创建
    spring当中的事务处理
    restTemplate调用操作出现乱码
    mysql中的any_value的基本使用操作
    DTD与XSD的区别
    idea的插件
  • 原文地址:https://www.cnblogs.com/110-913-1025/p/9088134.html
Copyright © 2020-2023  润新知