美文网首页
关于系统API

关于系统API

作者: 雨夜ll | 来源:发表于2018-11-01 15:00 被阅读0次

    以下API效果可以安全使用

    cube方块

    suckEffect三角

    rippleEffect水波抖动

    pageCurl上翻页

    pageUnCurl下翻页

    oglFlip上下翻转

    cameraIrisHollowOpen镜头快门开

    cameraIrisHollowClose镜头快门开

    以下API效果请慎用

    spewEffect新版面在屏幕下方中间位置被释放出来覆盖旧版面.

    genieEffect旧版面在屏幕左下方或右下方被吸走,显示出下面的新版面

    unGenieEffect新版面在屏幕左下方或右下方被释放出来覆盖旧版面.

    twist版面以水平方向像龙卷风式转出来.

    tubey版面垂直附有弹性的转出来.

    swirl旧版面360度旋转并淡出,显示出新版面.

    charminUltra旧版面淡出并显示新版面.

    zoomyIn新版面由小放大走到前面,旧版面放大由前面消失.

    zoomyOut新版面屏幕外面缩放出现,旧版面缩小消失.

    oglApplicationSuspend像按”home”按钮的效果.

    切换图片动画

    -(IBAction)buttonClick:(UIButton*)button

    {

        button.tag++;

       if(button.tag==3)

        {

            button.tag=0;

        }

       _imageView.image= [UIImageimageNamed:[NSStringstringWithFormat:@"%d",button.tag]];

       //私有api里的动画效果 (使用了不能上线)

    //    cube方块

    //    suckEffect三角

    //    rippleEffect水波抖动

    //    pageCurl上翻页

    //    pageUnCurl下翻页

    //    oglFlip上下翻转

    //    cameraIrisHollowOpen镜头快门开

    //    cameraIrisHollowClose镜头快门开

       //转场动画

    //    CATransaction

       CATransition  *transition = [CATransitionanimation];

       //设置动画效果

        transition.type=@"cameraIrisHollowOpen";

       //动画方向

        transition.subtype=kCATransitionFromRight;

        transition.duration=2;

       //添加动画

        [_imageView.layeraddAnimation:transitionforKey:nil];

    }

    核心动画

       //UIView动画是基于CALayer动画的封装

       //CALayer动画封装在QuartzCore框架中

       //CAAnimation动画的抽象类 一般使用子类

    //    CABasicAnimation 基础动画

    //    CAKeyframeAnimation关键帧动画

    //    CAAnimationGroup 动画组

    //    CATransition 转场动画(过渡动画)

    #import"ViewController.h"

    @interfaceViewController()

    {

       UIButton*_button;

    }

    @end

    @implementationViewController

    - (void)viewDidLoad {

        [superviewDidLoad];

       /*

        [UIView animateWithDuration:<#(NSTimeInterval)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

        */

       //UIView动画是基于CALayer动画的封装

       //CALayer动画封装在QuartzCore框架中

       //CAAnimation动画的抽象类 一般使用子类

    //    CABasicAnimation 基础动画

    //    CAKeyframeAnimation关键帧动画

    //    CAAnimationGroup 动画组

    //    CATransition 转场动画(过渡动画)

       _button= [UIButtonbuttonWithType:UIButtonTypeCustom];

       _button.bounds=CGRectMake(0,0,100,100);

       //锚点

       _button.layer.anchorPoint=CGPointMake(0,0);

       _button.layer.position=CGPointMake(100,100);

       _button.backgroundColor= [UIColorredColor];

        [_buttonsetTitle:@"按钮"forState:UIControlStateNormal];

        [_buttonaddTarget:selfaction:@selector(buttonClick:)forControlEvents:UIControlEventTouchUpInside];

        [self.viewaddSubview:_button];

    }

    //

    -(void)touchesBegan:(NSSet<UITouch*> *)touches withEvent:(UIEvent*)event

    {

       NSLog(@"touch---------");

       //动画

    //    [self baseAnimation];

    //    [self keyFrameAnimation];

        [selfanimationGroup];

    }

    //动画组

    -(void)animationGroup

    {

       //有一组基础动画组成

       CABasicAnimation*a1 = [CABasicAnimationanimationWithKeyPath:@"backgroundColor"];

        a1.fromValue= (id)[[UIColorredColor]CGColor];

        a1.toValue= (id)[[UIColorblueColor]CGColor];

       CABasicAnimation*a2 = [CABasicAnimationanimationWithKeyPath:@"transform.translation.x"];

        a2.fromValue= @-50;

        a2.toValue=@150;

       CABasicAnimation*a3 = [CABasicAnimationanimationWithKeyPath:@"transform.scale.y"];

        a3.fromValue=@1;

        a3.toValue=@1.5;

       CAAnimationGroup*group = [CAAnimationGroupanimation];

        group.animations=@[a1,a2,a3];

        group.duration=3;

        [_button.layeraddAnimation:groupforKey:nil];

    }

    //关键帧动画

    -(void)keyFrameAnimation

    {

       CAKeyframeAnimation*animation = [CAKeyframeAnimationanimation];

        animation.keyPath=@"transform.translation.y";

       //运动的过程,可以有多个值

        animation.values=@[@200,@(-100),@100,@(-50)];

       //设置运动每一帧所在的时间点

       //数组必须从0开始,到1结束

        animation.keyTimes=@[@0,@0.2,@0.8,@1];

       //持续时间

        animation.duration=3;

        [_button.layeraddAnimation:animationforKey:nil];

    }

    //基础动画

    -(void)baseAnimation

    {

       //基础动画一次只能改变一个属性的值

       //获取动画对象

       CABasicAnimation*animation = [CABasicAnimationanimation];

       //keyPath:控件属性名称 属性名称一定是layer的属性名称,因为动画是基于CALayer的动画

    //    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"];

       /* 位置

        animation.keyPath = @"position";

        //基本类型需要转换成NSNumber类型

        //结构体需要转换成NSValue类型

        //从fromValue变到toValue  50,50  --> 200,400

        animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(50, 50)];

        animation.toValue = [NSValue valueWithCGPoint:CGPointMake(200, 400)];

        */

       /*

        //大小  (50,50)-->(300,300)

        animation.keyPath = @"bounds";

        animation.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 50, 50)];

    //    animation.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 300, 300)];

        //大小  (50,50)-->(350,350)

        animation.byValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 300, 300)];

        */

       //基础动画一次只能改变一个属性的值,要么位置,要么大小

       /*  frame改变不了

        animation.keyPath = @"frame";

        animation.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, 50, 50)];

        animation.toValue = [NSValue valueWithCGRect:CGRectMake(200, 400, 100, 100)];

        */

       //平移 缩放 旋转

    //    animation.keyPath = @"transform";

       //平移

       //tx ty  tz :x,y,z三个轴上移动距离

    //    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(0, 0, 0)];

    //    animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-100, 300, 100)];

       //缩放

       //sx,sy,sz:x,y,z三轴上缩放比例

    //    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1, 1, 1)];

    //    animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(-1, -0.5, -1)];

       //angle 旋转角度

       //弧度角= angle * M_PI / 180

       //x,y,z轴方向旋转的比率。0不旋转

    //    animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(0, 0, 0, 0)];

    //    animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI, .3, 0.8, 0)];

       //指定某一个轴上的缩放

        animation.keyPath=@"transform.scale.x";

        animation.fromValue=@1;

        animation.toValue=@2;

      // CAMediaTiming 封装了动画的属性

       //动画持续时间

        animation.duration=2;

       //动画重复次数

    //    animation.repeatCount = 1;

       //在此时间内一直动画,直到时间耗尽

    //    animation.repeatDuration = 3;

       //设置动画延时

       //CACurrentMediaTime()当前时间

    //    animation.beginTime = CACurrentMediaTime() + 2;

       //代理

        animation.delegate=self;

       //让控件保留动画结束时候的位置

        animation.removedOnCompletion=NO;

      // kCAFillModeForwards动画结束时保留结束时候的状态

      // kCAFillModeBackwards动画开始时保留开始时候的状态

      // kCAFillModeBoth以上两种状态结合

        animation.fillMode=kCAFillModeBoth;

       //添加动画  key:动画的标示符

        [_button.layeraddAnimation:animationforKey:@"basicAnimation"];

       //CAAnimation动画过程中,控件本身其实没有动(控件的属性没有被修改)。 运动时,系统复制了一个和控件一样的layer,让这个layer运动。

       //需要自己写代码实现控件属性的改变

    //    _button.layer.position = CGPointMake(200, 400);

       //POP第三方动画Facebook

       //动画过程,控件的属性是被修改了的

    }

    - (void)animationDidStart:(CAAnimation*)anim

    {

       NSLog(@"开始动画。。。");

    }

    -(void)animationDidStop:(CAAnimation*)anim finished:(BOOL)flag

    {

       if(flag)

        {

           NSLog(@"动画结束");

        }

       else

        {

           NSLog(@"动画中断");

        }

    }

    -(void)buttonClick:(UIButton*)sender

    {

       NSLog(@"buttonClick++++++++++");

    }

    - (void)didReceiveMemoryWarning {

        [superdidReceiveMemoryWarning];

       // Dispose of any resources that can be recreated.

    }

    相关文章

      网友评论

          本文标题:关于系统API

          本文链接:https://www.haomeiwen.com/subject/cgrxxqtx.html