IOS第18天(5,CABasicAnimation基本动画)
*******
#import "HMViewController.h" @interface HMViewController () @property (nonatomic, weak) CALayer *layer; @end @implementation HMViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. CALayer *layer = [CALayer layer]; layer.position = CGPointMake(, ); layer.bounds = CGRectMake(, , , ); layer.backgroundColor = [UIColor redColor].CGColor; layer.contents = (id)[UIImage imageNamed:@"心"].CGImage; [self.view.layer addSublayer:layer]; _layer = layer; } //旋转的动画
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// 创建动画对象
CABasicAnimation *anim = [CABasicAnimation animation]; // 设置动画的属性
anim.keyPath = @"transform.scale"; // 设置属性改变的值
anim.toValue = @0.5; // 设置动画时长
anim.duration = 0.25; // 取消反弹
// 动画执行完毕之后不要把动画移除
anim.removedOnCompletion = NO; // 保持最新的位置
anim.fillMode = kCAFillModeForwards; // 重复动画的次数
anim.repeatCount = MAXFLOAT; // 给图层添加了动画
[_layer addAnimation:anim forKey:nil]; }
//移动的动画
- (void)position
{
// 创建动画对象
CABasicAnimation *anim = [CABasicAnimation animation]; // 设置动画的属性
anim.keyPath = @"position"; // 设置属性改变的值
anim.toValue = [NSValue valueWithCGPoint:CGPointMake(, )]; // 设置动画时长
anim.duration = ; // 取消反弹
// 动画执行完毕之后不要把动画移除
anim.removedOnCompletion = NO; // 保持最新的位置
anim.fillMode = kCAFillModeForwards; // 给图层添加了动画
[_layer addAnimation:anim forKey:nil];
} @end
IOS第18天(5,CABasicAnimation基本动画)的更多相关文章
- IOS第18天(6,CAKeyframeAnimation关键帧动画)
******* #import "HMViewController.h" @interface HMViewController () @property (weak, nonat ...
- 李洪强iOS经典面试题143-绘图与动画
李洪强iOS经典面试题143-绘图与动画 绘图与动画 CAAnimation的层级结构 CAPropertyAnimation是CAAnimation的子类,也是个抽象类,要想创建动画对象,应该使 ...
- 核心动画基础动画(CABasicAnimation)关键帧动画
1.在iOS中核心动画分为几类: 基础动画(CABasicAnimation) 关键帧动画(CAKeyframeAnimation) 动画组(CAAnimationGroup) 转场动画(CATran ...
- 荼菜的iOS笔记--UIView的几个Block动画
前言:我的第一篇文章荼菜的iOS笔记–Core Animation 核心动画算是比较详细讲了核心动画的用法,但是如你上篇看到的,有时我们只是想实现一些很小的动画,这时再用coreAnimation就会 ...
- iOS开发UI篇—iOS开发中三种简单的动画设置
iOS开发UI篇—iOS开发中三种简单的动画设置 [在ios开发中,动画是廉价的] 一.首尾式动画 代码示例: // beginAnimations表示此后的代码要“参与到”动画中 [UIView b ...
- IOS第18天(9,核心动画-动画组)
****动画组 // 核心动画都是假象,不能改变layer的真实属性的值// 展示的位置和实际的位置不同.实际位置永远在最开始位置 #import "HMViewController.h&q ...
- CABasicAnimation 基本动画 分类: ios技术 2015-07-16 17:10 132人阅读 评论(0) 收藏
几个可以用来实现热门APP应用PATH中menu效果的几个方法 +(CABasicAnimation *)opacityForever_Animation:(float)time //永久闪烁的动画 ...
- AJ学IOS(39)UI之核心动画之CABasicAnimation(基础动画)
AJ分享,必须精品 一.CABasicAnimation简介 CAPropertyAnimation的子类 属性解析: fromValue:keyPath相应属性的初始值 toValue:keyPat ...
- IOS第18天(10,核心动画-转盘,自定义buton,旋转动画)
*****HMViewController.m #import "HMViewController.h" #import "HMWheelView.h" @in ...
随机推荐
- Ubuntu mysql
To install mysql database in the ubuntu: 1. sudo apt-get install mysql-server 2. apt-get isntall ...
- I Hate It(线段树基础)
Time Limit: 9000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
- virtualtree 的使用(Delphi)
VirtualTreeview的强大,毋庸置疑,不过,你能给演示演示,也不错,就是刚下来,只有一个可执行程序,感觉像病毒. 最近比较忙,没有上网,现在把我研究的结果和大家通报下,方便新手学习,避免走弯 ...
- 【wpf】Path画扇形以及Path的Data属性的理解
<Path x:Name="PathFillColor" Fill="{TemplateBinding Property=Button.Background}&qu ...
- underscore.js依赖库函数分析二(查找)
查找: 在underscore.js封装了对dom查找的操作,find()和filter()函数,find()函数的查找操作是返回首个与条件相符的元素值,filter()函数是找到与条件相符的所有元素 ...
- 2014-2015 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
I. Sale in GameStore(贪心) time limit per test 2 seconds memory limit per test 512 megabytes input sta ...
- BZOJ4707 : B君的技巧
建立线段树,设$f[x][l][r]$表示当前考虑$x$点,最左端是$l$,最右端是$r$的最少代价. 如果$a$在$x<<1$,$d$在$x<<1|1$, 设$g[a][c] ...
- Codeforces Round #215 (Div. 2) C. Sereja and Algorithm
#include <iostream> #include <vector> #include <algorithm> #include <string> ...
- Android -- ProgressBar(进度条的使用)
我们在开发程序是经常会需要软件全屏显示.自定义标题(使用按钮等控件)和其他的需求,今天这一讲就是如何控制Android应用程序的窗体显示. requestWindowFeature可以设置的值有:(具 ...
- Linux下bash: scp: command not found问题 或者装ssh包时报错 Requires: libedit.so.0()(64bit)
一.用scp命令从物理主机向CentOS 6.1虚拟机传送文件,提示以下错误:bash: scp: command not found到CentOS 6.1虚拟机查看也缺少scp命令.该虚拟机 ...