动画

1.UIVIew  

1.1 动画块(改变背景颜色和移动)

static BOOL flag=YES;

    //开始动画

    [UIView beginAnimations:nil context:nil];

    //运动的时间

    [UIView setAnimationDuration:2.f];

    //延时启动

    [UIView setAnimationDelay:2.f];

    //速度曲线

    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

    //代理

    [UIView setAnimationDelegate:self];

    //开始时候执行

    [UIView setAnimationWillStartSelector:@selector(startAction)];

    //结束时候执行

   // [UIView setAnimationDidStopSelector:@selector(stopAction)];

    

    //重复执行

    [UIView setAnimationRepeatAutoreverses:YES];

    //重复执行次数

    [UIView setAnimationRepeatCount:5];

    

    //动画过程(换背景色)

    self.myView.backgroundColor=[UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0  blue:arc4random()%256/255.0  alpha:1];

    

    //改位置

    CGRect myFrame=self.myView.frame;

    if (flag) {

        //向下移动

         myFrame.origin.y+=100;

        myFrame.size.height+=150;

        flag=NO;

    }

    else

    {

        myFrame.origin.y-=100;

        myFrame.size.height-=150;

        flag=YES;

    }

   

    self.myView.frame=myFrame;

    self.myView.alpha=0.5;

    

    //提交动画

    [UIView commitAnimations];

************


 

1.2  block块

//自己的Block

    [self myAnimationDuration:2.f animaton:^{

        self.myView.backgroundColor=[UIColor grayColor];

    }];

    //系统提供的Block

    [UIView animateWithDuration:2.f animations:^{

        self.myView.backgroundColor=[UIColor greenColor];

    }];

    //第一个Block块执行动画

    //第二个Block块是在执行完动画后执行

    [UIView animateWithDuration:2.f animations:^{

        self.myView.backgroundColor=[UIColor greenColor];

    } completion:^(BOOL finished) {

        self.myView.backgroundColor=[UIColor redColor];

    }];

//自己定义的动画Block块方法

-(void)myAnimationDuration:(NSTimeInterval )time animaton:(animation)ani

{

    [UIView beginAnimations:nil context:nil];

    [UIView setAnimationDuration:time];

    ani();

    [UIView commitAnimations];

}

***********


 

 1.3UIViewYransition

    //第一个方法

    [UIView transitionWithView:self.myView duration:2.f options:(UIViewAnimationOptionTransitionFlipFromBottom) animations:^{

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

    } completion:^(BOOL finished) {

        NSLog(@"动画结束了");

    }];

    //第二个方法

    [UIView transitionWithView:<#(UIView *)#> duration:<#(NSTimeInterval)#> options:<#(UIViewAnimationOptions)#> animations:<#^(void)animations#> completion:<#^(BOOL finished)completion#>]

 

 


 

2.CGAffineTransfrom

    [UIView animateWithDuration:2.f animations:^{

        //缩小(基于前一次变化)

       self.myView.transform=CGAffineTransformScale(self.myView.transform, 0.2f, 0.2f);

        //旋转(基于前一次变化)

        self.myView.transform=CGAffineTransformRotate(self.myView.transform, M_PI);

               }];


 

3.CALayer 的属性

 //设置圆角

    self.myView.layer.cornerRadius=50;

    //边框颜色

    self.myView.layer.borderWidth=20;

    self.myView.layer.borderColor=[UIColor redColor].CGColor;

    //阴影颜色

    self.myView.layer.shadowColor=[UIColor grayColor].CGColor;

    //阴影偏移

    self.myView.layer.shadowOffset=CGSizeMake(-10, 10);

    //透明度必须设置

    self.myView.layer.shadowOpacity=0.3;

    //模糊程度

    self.myView.layer.shadowRadius=4;

    //设置锚点

    self.myView.layer.anchorPoint=CGPointMake(.5, .5);

*****************************


********************

4.CAPropertyAnimation (两个子类CABasicAnimation和CAKeyframeAnimation)

4.1.CABasicAnimation

//CALayer    

    //UIView的属性动画,会修改属性产生动画.

    //CALayer,没有修改UIView属性

    //创建animation对象

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

    //从那儿开始

    animation.fromValue=[NSValue valueWithCGPoint:self.myView.layer.position];

    //到哪儿结束

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

    //设置时间

    animation.duration=2.0;

    //自动执行

    animation.autoreverses=YES;

    //执行次数

    animation.repeatCount=3;

     //添加到self.view.layer

    [self.myView.layer addAnimation:animation forKey:@"position动画"];

 

//缩放动画

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];

    //初始值

    animation.fromValue=[NSNumber numberWithFloat:1.0];

   //结束值

    animation.toValue=[NSNumber numberWithFloat:3.0];

    //设置时间

    animation.duration=0.1;

    自动执行

    animation.autoreverses=YES;

     //执行次数

    animation.repeatCount=100;

    //添加到self.view.layer

    [self.myView.layer addAnimation:animation forKey:@"缩放动画"];


 

4.2CAKeyframeAnimation

//指定位置移动

CAKeyframeAnimation *animation=[CAKeyframeAnimation animationWithKeyPath:@"position"];

    //持续时间

    animation.duration=2.0;

    //自动

    animation.autoreverses=YES;

    //此数

    animation.repeatCount=30;

    NSArray *array=@[[NSValue valueWithCGPoint:CGPointMake(50, 50)],[NSValue valueWithCGPoint:CGPointMake(200, 25)],[NSValue valueWithCGPoint:CGPointMake(25, 200)],[NSValue valueWithCGPoint:CGPointMake(200, 200)]];

        animation.values=array;

    //添加到self.view.layer

     [self.myView.layer addAnimation:animation forKey:@"动画"];

*****************************************


 

5.CAAnimationGroup

    CAAnimationGroup *group=[CAAnimationGroup animation];

    

    //第一个动画

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];

    animation.fromValue=[NSNumber numberWithFloat:1.0];

    animation.toValue=[NSNumber numberWithFloat:3.0];

    //第二个动画

    CAKeyframeAnimation *animation1=[CAKeyframeAnimation animationWithKeyPath:@"position"];

 

    NSArray *arr=@[[NSValue valueWithCGPoint:CGPointMake(50, 50)],[NSValue valueWithCGPoint:CGPointMake(200, 50)],[NSValue valueWithCGPoint:CGPointMake(50, 200)],[NSValue valueWithCGPoint:CGPointMake(200, 200)]];

   animation1.values=arr;

   //添加到动画数组

    group.animations=@[animation,animation1];

    group.duration=1;

    group.autoreverses=YES;

    group.repeatCount=500;

    

    //数组添加到view的layer

    [self.myView.layer addAnimation:group forKey:@"组合"];


 

6.CATransition

 /*

    pageCurl            向上翻一页 

     pageUnCurl          向下翻一页 

     rippleEffect        滴水效果 

     suckEffect          收缩效果,如一块布被抽走 

     cube                立方体效果 

     oglFlip             上下翻转效果

    */

    

    CATransition *ani=[CATransition animation];

    ani.type=@"cube";

    ani.subtype=kCATransitionFromLeft;

    ani.duration=2;

    ani.repeatCount=30;

    [self.myView.layer addAnimation:ani forKey:@"动画"];

    


 

UIAnimation包括三个子类:(CAnimationGroup. CAPropertyAnimation(两个子类CABasicAnimation,CAkeyFraneAnimation).CATransition)

 

 

 


 

转载于:https://www.cnblogs.com/haiying/p/4125303.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/359404.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

app engine_Google App Engine:在您自己的域中托管应用程序

app engine在Google App Engine中创建新应用程序时&#xff0c;您将获得一个域名“ yourapp.appspot.com”。 但是&#xff0c;谁会想要以这样的后缀托管他们的应用程序&#xff08;除非您喜欢它&#xff01;&#xff09;&#xff1f; 为了改善您的应用程序品牌&#xff0c;最好…

mysql二进制大文件_Mysql实例Mysql LONGTEXT 类型存储大文件(二进制也可以) (修改+调试+整理)...

《Mysql实例Mysql LONGTEXT 类型存储大文件(二进制也可以) (修改调试整理)》要点&#xff1a;本文介绍了Mysql实例Mysql LONGTEXT 类型存储大文件(二进制也可以) (修改调试整理)&#xff0c;希望对您有用。如果有疑问&#xff0c;可以联系我们。#include "stdafx.h"/…

bzoj2243 [SDOI2011]染色

Description 给定一棵有n个节点的无根树和m个操作&#xff0c;操作有2类&#xff1a; 1、将节点a到节点b路径上所有点都染成颜色c&#xff1b; 2、询问节点a到节点b路径上的颜色段数量&#xff08;连续相同颜色被认为是同一段&#xff09;&#xff0c;如“112221”由3段组成&am…

阿里云mysql创建多个用户_阿里云MySQL创建指定用户访问指定表

欢迎大家关注我的公众号&#xff0c;有问题可以及时和我交流。1.首先进入到root用户环境mysql -uroot -p输入自己的root密码登录。登录成功之后如果表之前已经存在的话就不需要创建&#xff0c;如果表不存在的话使用创建表命令创建。create database table&#xff1b;2.给用户…

自定义实现moveable button

实现的效果图&#xff1a; 自定义MVButton&#xff0c;继承自UIButton. 属性声明如下&#xff1a; property (nonatomic) CGPoint beginPoint; property (nonatomic) BOOL dragEnable;//自定义button对触摸事件进行响应- (void)touchesBegan:(NSSet *)touches withEvent:(UI…

jOOQ星期二:Vlad Mihalcea深入了解SQL和Hibernate

欢迎来到jOOQ Tuesdays系列。 在本系列中&#xff0c;我们每隔一个月的第三个星期二发布一篇文章&#xff0c;从jOOQ的角度采访我们发现该行业令人兴奋的人。 这包括从事SQL&#xff0c;Java&#xff0c;开放源代码以及其他各种相关主题的人员。 我们很高兴在第三版中与Vlad …

python编程序列类型_python序列类型种类详解

python序列类型包括哪三种python序列类型包括&#xff1a;列表、元组、字典列表&#xff1a;有序可变序列创建&#xff1a;userlist [1,2,3,4,5,6]修改&#xff1a;userlist[5] 999添加&#xff1a;userlist.append(777)删除&#xff1a;userlist.remove(4) 或者 del(userlis…

GitHub初次使用记录(一)

1、从GitHub上克隆或者复制别人的档案库&#xff1a; 克隆档案库时需要打开本地Git客户端&#xff08;比如GitHub for Windows 和 GitExtesnsion &#xff09;操作。 下面是用GitExtension克隆档案库&#xff1a; 转载于:https://www.cnblogs.com/lxf1117/p/4140048.html

mysql中逗号前的字符串_MySql逗号拼接字符串查询的两种方法

下面两个函数的使用和FIND_IN_SET一样,使用时只需要把FIND_IN_SET换成FIND_PART_IN_SET或FIND_ALL_PART_IN_SET例如某字段里是为1,2,3,4,5使用方法:第一种,传入1,3,6 可以查出来 select * from XXX where FIND_PART_IN_SET(1,3,6,1,2,3,4,5)第二种,传入1,3,6 查不出来 select *…

使用Maven,Jetty和Tomcat在嵌入式容器中运行Java Web应用程序

在开发Java Web应用程序时&#xff0c;从“真实”环境中获得快速反馈非常实用。 在本文中&#xff0c;我将探讨如何在嵌入式容器Jetty或Tomcat中运行带有Maven的Java Web应用程序。 在Podcastpedia.org网站的支持下&#xff0c;我将展示如何配置它们以开发podcastpedia项目。 …

Linux下查看文件和文件夹大小

当磁盘大小超过标准时会有报警提示&#xff0c;这时如果掌握df和du命令是非常明智的选择。 df可以查看一级文件夹大小、使用比例、档案系统及其挂入点&#xff0c;但对文件却无能为力。 du可以查看文件及文件夹的大小。 两者配合使用&#xff0c;非常有效。比如用df查看哪个…

moosefs mysql_moosefs搭建与应用

moosefs搭建与应用MooseFS简介&#xff1a;MooseFS是一个具备冗余容错功能的分布式网络文件系统&#xff0c;它将数据分别存放在多个物理服务器单独磁盘或分区上&#xff0c;确保一份数据有多个备份副本。因此MooseFS是一中很好的分布式存储。接下来我们通过搭建moosefs&#x…

Audio Offload

Audio Offload 音频分载&#xff0c;是系统将音频分载到声卡硬件进行分载处理的功能。从Windows 8开始&#xff0c;音频的硬件加速和分载处理又回来了。为什么说又回来了呢&#xff1f; 因为声卡自创通公司发明开始&#xff0c;相当长一段时间都是由声卡独立完成所有音频处理的…

mysql数据库迁徙_mysql数据迁徙详解

数据迁徙是每个后端都会遇到的工作之一&#xff0c;本文介绍了一些常见的数据迁徙方法与工具mysqldump&#xff1a;数据结构不变的数据迁徙导出数据 mysqldump -u root -p DATABASE_NAME table_name > dump.sql恢复数据 mysql -u root -p DATABESE_NAME < dump.sql或者连…

junit-4.9.jar_JUnit 4.9(测试版3)中的规则

junit-4.9.jar不久前&#xff0c; David Saff宣布了JUnit 4.9的beta版 。 因此&#xff0c;我认为现在是研究该版本中的新增功能的好时机。 JUnit领域中最有用的创新之一是Rule。 我在这里写了有关规则的文章 。 我在这里写了有关JUnit规则的用例 。 规则很棒。 借助JUnit 4.9&…

封装js千分位加逗号和删除逗号

//封装js千分位加逗号和删除逗号alert( format(2545678754.020001) ) //2,545,678,754.03alert( format(-2545678754.020001) ) //-2,545,678,754.02alert( format(2545678754.000000000009) ); //当值很长的时候会出现数字被截取的问题alert( delformat(2,545,678,75…

java集成_Java继承

一.继承1.简介&#xff1a;特点&#xff1a;利于代码复用&#xff1b;缩短开发周期。注&#xff1a;子类不能直接访问父类的私有属性满足“A is a B”的关系就可以形成继承关系例&#xff1a;父类&#xff1a;1 packagecom.swpu.animals;23 public classAnimal {4 //属性5 priv…

查找任意数目参数的最大值

查找任意数目参数的最大值 原文:查找任意数目参数的最大值《C和指针》第7章第4道编程题&#xff1a; 编写一个名叫max_list的函数&#xff0c;它用于检查任意数目的整型参数并返回它们中的最大值。参数列表必须以一个负值结尾&#xff0c;提示列表的结束。 1 /*2 ** 查找任意数…

如何以大数据的JAX-RS响应的形式将JPA结果流化/序列化

有时&#xff0c;有必要通过JPA检索大型数据集&#xff08;例如&#xff0c;超过1,000,000条记录&#xff09;&#xff0c;并将它们填充到java.util.List的单个实例中是有风险的&#xff08;内存障碍&#xff09;。 因此&#xff0c;这是一个快速的解决方案&#xff0c;它可以解…

Tab标签页接口---使用Intent对象

TabHost tabHost getTabHost();Intent it new Intent();it.setClass(Main.this, DateTimePicker.class);TabSpec spectabHost.newTabSpec("tab1");spec.setContent(it);spec.setIndicator("ら戳㎝丁",getResources().getDrawable(android.R.drawable.i…