核心动画(CAKeyframeAnimation)
Main.storyboard

ViewController.m
//
// ViewController.m
// 8A02.核心动画 - CAKeyframeAnimation
//
// Created by huan on 16/2/4.
// Copyright © 2016年 huanxi. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//添加一个圆
CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
UIView *circleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screenW, screenW)];
circleView.backgroundColor = [UIColor yellowColor];
//设置圆角
circleView.layer.cornerRadius = screenW * 0.5;
[self.view addSubview:circleView];
//把图片移到顶部
[self.view bringSubviewToFront:self.imageView];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//学习帧动画
//创建一个帧动画
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.keyPath = @"position";
//设置动画执行路径 指定四个点
NSValue *value1 = [NSValue valueWithCGPoint:CGPointMake(50, 50)];
NSValue *value2 = [NSValue valueWithCGPoint:CGPointMake(250, 50)];
NSValue *value3 = [NSValue valueWithCGPoint:CGPointMake(250, 250)];
NSValue *value4 = [NSValue valueWithCGPoint:CGPointMake(50, 250)];
//数组第一个是"开始状态" 最后一个是“结束状态”
animation.values = @[value1, value2, value3, value4, value1];
//设置时间
animation.duration = 3;
//设置动画节奏
// kCAMediaTimingFunctionEaseIn 先慢后快
// kCAMediaTimingFunctionEaseOut 先慢后快
// kCAMediaTimingFunctionEaseOut 线性匀速
// kCAMediaTimingFunctionEaseInEaseOut 中间快两边慢
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
#warning 内部的path的优先级大于values优先级
//设置路径
CGMutablePathRef path = CGPathCreateMutable();
CGFloat screenW = [UIScreen mainScreen].bounds.size.width;
CGPathAddEllipseInRect(path, NULL, CGRectMake(0, 0, screenW, screenW));
animation.path = path;
//c语言的数据类型,如果create/copy/retain 创建要释放
//添加动画
[self.imageView.layer addAnimation:animation forKey:nil];
}
@end
结果

核心动画(CAKeyframeAnimation)的更多相关文章
- 核心动画 - CAKeyframeAnimation 简单应用
核心动画: 登录按钮的抖动效果: CAKeyframeAnimation * kfAnimation = [CAKeyframeAnimation animationWithKeyPath:@&quo ...
- IOS 核心动画(Core Animation)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它 能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就 可以实现非常强大的功能. Core ...
- AJ学IOS(40)UI之核心动画_抖动效果_CAKeyframeAnimation
AJ分享,必须精品 效果: 效果一: 效果二: 代码: // // NYViewController.m // 图片抖动 // // Created by apple on 15-5-8. // Co ...
- IOS 核心动画之CAKeyframeAnimation - iBaby
- IOS 核心动画之CAKeyframeAnimation - 简单介绍 是CApropertyAnimation的子类,跟CABasicAnimation的区别是:CABasicAnimation ...
- iOS:核心动画之关键帧动画CAKeyframeAnimation
CAKeyframeAnimation——关键帧动画 关键帧动画,也是CAPropertyAnimation的子类,与CABasicAnimation的区别是: –CABasicAnimation只能 ...
- 核心动画(CAKeyframeAnimation,CABasicAnimation)
一,核心动画常用的三种例子 view的核心动画其体现就是把view按照指定好的路径进行运动,针对的是view的整体. [view.layer addAnimation:动画路径 forKey:@“绑定 ...
- CoreAnimation 核心动画 / CABasicAnimation/ CAKeyframeAnimation
- (void)createBaseAnimation{ //基础动画 CABasicAnimation *animation = [CABasicAnimation animation]; anim ...
- ios开发核心动画五:图标抖动效果--CAKeyframeAnimation
#import "ViewController.h" #define angle2Rad(angle) ((angle) / 180.0 * M_PI) @interface Vi ...
- iOS开发UI篇—核心动画(关键帧动画)
转自:http://www.cnblogs.com/wendingding/p/3801330.html iOS开发UI篇—核心动画(关键帧动画) 一.简单介绍 是CApropertyAnimatio ...
随机推荐
- MIME Type
一.首先,我们要了解浏览器是如何处理内容的.在浏览器中显示的内容有 HTML.有 XML.有 GIF.还有 Flash --那么,浏览器是如何区分它们,决定什么内容用什么形式来显示呢?答案是 MIME ...
- linux命令行下的ftp 多文件下载和目录下载
安装:yum install ftp 使用:ftp + ip (未进入ftp状态下运行) ----------------------------------------- 目标ftp服务器是一个非标 ...
- jQuery(window) 和 jQuery(document)的区别
jQuery(window).height()代表了当前可见区域的大小,而jQuery(document).height()则代表了整个文档的高度,可视具体情况使用
- HDU1075
题目大意: 给你一本火星词典,每个火星单词对应一个英文单词. 然后给你一篇火星文章,要求你翻译成英文. 要求如下: 如果这个火星单词用英文单词可以表示,就翻译成英文,如果没有这个单词,就原样输出.遇到 ...
- Flyweight(享元)--对象结构型模式
1.意图 运用共享技术有效地支持大量细粒度的对象. 2.动机 Flyweight模式描述了如何共享对象,使得可以细粒度地使用它们,而无需高昂的代价.flyweight是一个共享对象,它可以同时在多个场 ...
- sublime text3的安装与汉化
sublime text3 3126 64位的下载地址: https://download.sublimetext.com/Sublime%20Text%20Build%203126%20x64%20 ...
- XtraGrid RepositoryItemCheckEdit 显示状态以及单选多选问题
RepositoryItemCheckEdit默认有三种状态,选中状态.未选中状态和半选中状态(半选中状态通常用在TreeList中如果父节点下的子节点有选中的有未选中的,则父节点状态为半选中状态). ...
- apache结合svn创建svn资源库
1.在登录过程中可以查看error日志,如果发生以下提示: (13)Permission denied: Could not open password file 2.运行:chcon -R -h - ...
- css3新特性@rgba
1.rgba也经常在实际应用中使用,它主要是在原来rgb的基础上添加了一透明度.但是他又和opacity又有一些差别,主要体现在对子元素的透明度的影响上. 例如:使用opacity和backgroun ...
- 让padding、border等不占据宽度
box-sizing:border-box; -moz-box-sizing:border-box; /* Firefox */ -webkit-box-sizing:border-box; /* S ...