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将为这些改变提供动画 ...
随机推荐
- http://blog.csdn.net/luoshengyang/article/details/6651971
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6651971 在Android系统中,提供了独特 ...
- LabView培训
labview基础到高级官方超全完整视频教程包括数据采集,其他模块的部 分教程,废话不多说. 免费下载地址在结尾. LabVIEW 本事编程(低级)培训LabVIEW作为前辈的图形化编程言语斥地环境, ...
- DBSNMP和SYSMAN用户初始密码及正确的修改方式
SYSMAN和DBSNMP跟涉及到Oracle的EM,所以跟其他的用户修改密码方式有所区别. 下面是这两个用户的默认密码和作用说明 DBSNMP DBSNMP The account used by ...
- Sublime 学习记录(二) package control 组件
i. 按Ctrl + ` 调出console (如果有QQ输入法会有冲突需要关闭热键) ii. 粘贴以下代码到底部命令行并运行 import urllib.requ ...
- struts1面试题
由于找了很久的工作都没有找的,只能四处收集那个面试题的.和看面试题的 还有那个记忆力也不是很好了的,而那些公司面试的时候总会有一个面试题的! 在这里分享给大家(那个本来是想上传文件的,但是找不到的 ...
- [转]eclipse下编写android程序突然不会自动生成R.java文件和包的解决办法
原网址 : http://www.cnblogs.com/zdz8207/archive/2012/11/30/eclipse-android-adt-update.html 网上解决方法主要有这几种 ...
- ios 调用相机后 view 下沉问题
我只加了一句代码 现在不报错了 因为这个问题是随机性的 我也不太明白这个地方是怎么回事 我只是这样子做了 问题不出来了 if ([[[UIDevice currentDevice] syst ...
- ETL概述
转自:http://blog.csdn.net/leosoft/article/details/4279536 ETL,Extraction-Transformation-Loading的缩写,中文名 ...
- ansilbe 入门001、ansible的介绍
概述: ansible 作为一个配置管理工具.首先我们要“告诉”它管理的是那几台机器啊:而这个信息就在要ansible 的配置文件中体现了.默认情况下ansible的配置文件保存在 /etc/ansi ...
- What is an http upgrade?
HTTP Upgrade is used to indicate a preference or requirement to switch to a different version of HTT ...