#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常用的几个动画代码的更多相关文章

  1. iOS学习笔记-自定义过渡动画

    代码地址如下:http://www.demodashi.com/demo/11678.html 这篇笔记翻译自raywenderlick网站的过渡动画的一篇文章,原文用的swift,由于考虑到swif ...

  2. IOS 制作动画代码和 设置控件透明度

    方式1: //animateWithDuration用1秒钟的时间,执行代码 [UIView animateWithDuration:1.0 animations:^{ //存放需要执行的动画代码 s ...

  3. iOS常用第三方开源框架和优秀开发者博客等

    博客收藏iOS开发过程好的开源框架.开源项目.Xcode工具插件.Mac软件.文章等,会不断更新维护,希望对你们有帮助.如果有推荐或者建议,请到此处提交推荐或者联系我. 该文档已提交GitHub,点击 ...

  4. iOS 常用三方类库整理

    iOS 常用三方类库整理 1:基于响应式编程思想的oc 地址:https://github.com/ReactiveCocoa/ReactiveCocoa 2:hud提示框 地址:https://gi ...

  5. iOS常用技术

    1.判断系统 #define UMSYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersi ...

  6. IOS常用第三方库《转》

    UI 动画 网络相关 Model 其他 数据库 缓存处理 PDF 图像浏览及处理 摄像照相视频音频处理 响应式框架 消息相关 版本新API的Demo 代码安全与密码 测试及调试 AppleWatch ...

  7. iOS常用基础框架

    一,简述  1.1,IOS操作系统的层次架构         iOS为应用程序开发提供了许多可使用的框架,并构成IOS操作系统的层次架构,分为四层,从上到下依次为:Cocoa Touch Layer( ...

  8. iOS常用第三方库大全,史上最全第三方库收集

    下拉刷新 EGOTableViewPullRefresh – 最早的下拉刷新控件. SVPullToRefresh – 下拉刷新控件. MJRefresh – 仅需一行代码就可以为UITableVie ...

  9. iOS开发UI篇—核心动画(UIView封装动画)

    iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...

随机推荐

  1. 游标的使用实例(Sqlserver版本)

    游标,如果是之前给我说这个概念,我的脑子有二个想法:1.你牛:2.我不会 不会不是理由,更不是借口,于是便要学习,本人属性喜欢看代码,不喜欢看书的人,所以嘛,文字对我没有吸引力:闲话少说啊,给大家提供 ...

  2. 浅谈NoSQL之MongoDB数据库

    对于SQL数据库(关系型数据库)我们大家都有所了解,比如MySQL,sqlserver,oracle等数据库.在日常的开发过程中我们遇到服务器端的数据存储时几乎第一反应就是使用SQL据库像我们最常见的 ...

  3. Highcharts 非常实用的Javascript统计图

    Highcharts 官网: http://www.highcharts.com Highcharts 官网示例:http://www.highcharts.com/demo/ Highcharts ...

  4. 在Unity3d编辑器中加入菜单以及菜单项

    在引用UZGUI插件时,u3d编辑器的菜单条发生了变化,新增了菜单和菜单项,于是乎自己也像尝试一下,看了EZGUI的About_EZ_GUI脚本文件后,结果大出我所料,原来SO EASY! using ...

  5. sqlserver中几种典型的等待

    为了准备今年的双11很久没有更新blog,在最近的几次sqlserver问题的排查中,总结了sqlserver几种典型的等待类型,类似于oracle中的等待事件,如果看到这样的等待类型时候能够迅速定位 ...

  6. C函数的实现(strcpy,atoi,atof,itoa,reverse)

    在笔试面试中经常会遇到让你实现C语言中的一些函数比如strcpy,atoi等 1. atoi 把字符串s转换成数字 int Atoi( char *s ) { int num = 0, i = 0; ...

  7. BASE64Encoder问题类

    于myeclipse于BASE64Encoder提示类不出现 对当前右击project-->Build Path--->Configure Build Path--->Java Bu ...

  8. QtXlsxWriter

    Code Issues26 Pull requests2   Pulse Graphs HTTPS clone URL You can clone with HTTPS orSubversion. C ...

  9. easyui-combobox绑定json数据

    用的C#语言 后台取数据,就不用废话了,先看看序列化json数据 /// <summary> /// 对象转JSON /// </summary> /// <param ...

  10. ie11加载不了css的问题

    ie11打开页面,竟然一点css都没有加载出来,而且是老大的电脑遇到了这个问题,啃爹啊 上网查资料,做了如下修改: 1.pc端最好不要用h5来写页面,兼容性是个头疼的问题,切记切记(移动端可以用H5来 ...