ios常用的几个动画代码
#import "MianViewController.h"
#import <QuartzCore/QuartzCore.h> @interface MianViewController ()
{
UIImageView *shakeFeedbackOverlay;
NSTimer *rotateTimer;
int timeCount;
} @end @implementation MianViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view. self.title = @"View翻转"; // shakeFeedbackOverlay.alpha = 0.0;
// shakeFeedbackOverlay.layer.cornerRadius = 10.0; //设置圆角半径 shakeFeedbackOverlay = [[UIImageView alloc]initWithFrame:CGRectMake(, , , )];
shakeFeedbackOverlay.backgroundColor = [UIColor redColor];
[self.view addSubview:shakeFeedbackOverlay]; /**左右摇动**/
/*
CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
shake.fromValue = [NSNumber numberWithFloat:-M_PI/32];
shake.toValue = [NSNumber numberWithFloat:+M_PI/32];
shake.duration = 0.1;
shake.autoreverses = YES; //是否重复
shake.repeatCount = 20;
[shakeFeedbackOverlay.layer addAnimation:shake forKey:@"shakeAnimation"];
shakeFeedbackOverlay.alpha = 1.0;
[UIView animateWithDuration:5.0 delay:0.0 options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction animations:^{
shakeFeedbackOverlay.alpha = 0.0; //透明度变0则消失
} completion:nil];
*/ /**顺时针旋转**/
/*
CABasicAnimation* shake = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
shake.fromValue = [NSNumber numberWithFloat:0];
shake.toValue = [NSNumber numberWithFloat:2*M_PI];
shake.duration = 0.8;
shake.autoreverses = NO;
shake.repeatCount = 99999;
[shakeFeedbackOverlay.layer addAnimation:shake forKey:@"shakeAnimation"];
shakeFeedbackOverlay.alpha = 1.0;
[UIView animateWithDuration:10.0 delay:0.0 options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction animations:^{
shakeFeedbackOverlay.alpha = 0.0;
} completion:nil];
*/ /*
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
CGMutablePathRef aPath = CGPathCreateMutable();
CGPathMoveToPoint(aPath, nil, 20, 20);
CGPathAddCurveToPoint(aPath, nil, 160, 30, 220, 220, 240, 420);
animation.path = aPath;
animation.autoreverses = YES;
animation.duration = 2;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
animation.rotationMode = @"auto";
[shakeFeedbackOverlay.layer addAnimation:animation forKey:@"position"];
*/ /**组合动画**/
/*
CABasicAnimation *flip = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
flip.toValue = [NSNumber numberWithDouble:-M_PI];
CABasicAnimation *scale= [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.toValue = [NSNumber numberWithDouble:12];
scale.duration = 1.5;
scale.autoreverses = YES;
CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = [NSArray arrayWithObjects:flip, scale, nil];
group.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
group.duration = 3;
group.fillMode = kCAFillModeForwards;
group.removedOnCompletion = NO;
[shakeFeedbackOverlay.layer addAnimation:group forKey:@"position"];
*/ /*指定时间内旋转图片*/
timeCount = ; //动画执行100次
[self startRotate]; } //启动定时器旋转光圈 - (void)startRotate
{
rotateTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(rotateGraduation)
userInfo:nil
repeats:YES];
} //关闭定时器
- (void)stopTimer
{
if ([rotateTimer isValid])
{
[rotateTimer invalidate];
rotateTimer = nil;
}
} //旋转动画
- (void)rotateGraduation
{
timeCount--;
if (timeCount == )
{
[self stopTimer];
// doSomeThing //旋转完毕 可以干点别的
timeCount = ;
}
else
{
//计算角度 旋转
static CGFloat radian = * (M_PI * / );
CGAffineTransform transformTmp = shakeFeedbackOverlay.transform;
transformTmp = CGAffineTransformRotate(transformTmp, radian);
shakeFeedbackOverlay.transform = transformTmp; }; }
ios常用的几个动画代码的更多相关文章
- iOS学习笔记-自定义过渡动画
代码地址如下:http://www.demodashi.com/demo/11678.html 这篇笔记翻译自raywenderlick网站的过渡动画的一篇文章,原文用的swift,由于考虑到swif ...
- IOS 制作动画代码和 设置控件透明度
方式1: //animateWithDuration用1秒钟的时间,执行代码 [UIView animateWithDuration:1.0 animations:^{ //存放需要执行的动画代码 s ...
- iOS常用第三方开源框架和优秀开发者博客等
博客收藏iOS开发过程好的开源框架.开源项目.Xcode工具插件.Mac软件.文章等,会不断更新维护,希望对你们有帮助.如果有推荐或者建议,请到此处提交推荐或者联系我. 该文档已提交GitHub,点击 ...
- iOS 常用三方类库整理
iOS 常用三方类库整理 1:基于响应式编程思想的oc 地址:https://github.com/ReactiveCocoa/ReactiveCocoa 2:hud提示框 地址:https://gi ...
- iOS常用技术
1.判断系统 #define UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersi ...
- IOS常用第三方库《转》
UI 动画 网络相关 Model 其他 数据库 缓存处理 PDF 图像浏览及处理 摄像照相视频音频处理 响应式框架 消息相关 版本新API的Demo 代码安全与密码 测试及调试 AppleWatch ...
- iOS常用基础框架
一,简述 1.1,IOS操作系统的层次架构 iOS为应用程序开发提供了许多可使用的框架,并构成IOS操作系统的层次架构,分为四层,从上到下依次为:Cocoa Touch Layer( ...
- iOS常用第三方库大全,史上最全第三方库收集
下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITableVie ...
- iOS开发UI篇—核心动画(UIView封装动画)
iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...
随机推荐
- android中创建模拟器的 SDCard
在eclipse中安装了android环境后,可以直接创建AVD和sdcard的,windows->Android Virtual Device Manager,创建一个AVD时,可以同时创建s ...
- UGUI Button和Toogle动态添加事件
如果你想动态创建Button和Toogle 等等一系列控件,需要动态添加事件的如下. 拿button和Toogle抛砖引玉O(∩_∩)O~ using UnityEngine; using Syste ...
- springmvc工作原理和环境搭建
SpringMVC工作原理 上面的是springMVC的工作原理图: 1.客户端发出一个http请求给web服务器,web服务器对http请求进行解析,如果匹配DispatcherServle ...
- 数据库中简单的增删改查(CRUD)
一切都是基于数据,而对数据的管理都离不开数据库.最近学到数据库的简单操作,所以写下这篇文章,总结一下学习到的知识.浅陋之处,多多见谅. 补充一下:一直弄不清SQL Server,Mysql ,以及Or ...
- ArcGIS Runtime SDK for Android开发之调用GP服务(异步调用)
一.背景说明 通过调用GP服务,Android客户端也能实现专业的.复杂的GIS分析处理功能,从而增加应用的实用价值. ArcGIS Server发布的GP服务,分为同步和异步两种类型,一般执行步骤较 ...
- mmc加工配套问题
题目如下,本题还有其它解.
- [视频] x264 压缩笔记
转载本站文章请注明,转载自:扶凯[http://www.php-oa.com] 本文链接: http://www.php-oa.com/2009/03/22/x264.html 象x264本身是不能直 ...
- Oracle 更改用户名
直接更改系统user$表中的用户名. 查询要更改的用户名 SQL> select user#,name,password from user$ where name ='TICKETS'; US ...
- NOT 运算符
NOT运算符不是独立的,它是一个可以放在任何逻辑表达式前面的修饰符,能得到与结果相反的结果.所以,如果一个表达式是真,就会得到假:如果是假,就会得到真.有时测试查找条件的反面更容易.不过,NOT运算符 ...
- js静态方法
1.ajax() 方法是属于“函数”本身的,和返回的对象没有关系 2.bark药调用,必须药new Hashiqi()得到对象,且由返回对象才能调用 3.ajax()方法药调用,不需要new对象,直接 ...