//
// ViewController.m
// 30-核心动画
//
// #import "ViewController.h"
@interface ViewController ()
@property(nonatomic,weak)CALayer *layer;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
UIView *redView =[[UIView alloc] init];
redView.frame =CGRectMake(100, 100, 20, 20);
redView.backgroundColor =[UIColor redColor];
self.layer=redView.layer ;
[self.view addSubview:redView];
} - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//组动画
CAAnimationGroup *group = [[CAAnimationGroup alloc] init];
//创建动画对象 (做什么动画)
CABasicAnimation *anim = [[CABasicAnimation alloc]init];
anim.keyPath = @"transform.rotation";
anim.byValue =@(2*M_PI*10);
CAKeyframeAnimation *anim1=[[CAKeyframeAnimation alloc] init];
anim1.keyPath = @"position";
UIBezierPath * path=[UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:100 startAngle:0 endAngle:2*M_PI clockwise:1];
anim1.path = path.CGPath;
group.animations=@[anim,anim1];
group.duration = 3;
group.repeatCount = INT_MAX; // 重复的次数
//怎么做动画
//添加动画(对谁做动画)
[self.layer addAnimation:group forKey:nil];
}
//关键帧
-(void)test2{
//关键帧
//创建动画对象 (做什么动画)
CAKeyframeAnimation *anim = [[CAKeyframeAnimation alloc] init];
//怎么做动画
anim.keyPath=@"position";
/* NSValue *v1 =[NSValue valueWithCGPoint:CGPointMake(100, 100)];
NSValue *v2 =[NSValue valueWithCGPoint:CGPointMake(150, 100)];
NSValue *v3 =[NSValue valueWithCGPoint:CGPointMake(100, 150)];
NSValue *v4 =[NSValue valueWithCGPoint:CGPointMake(150,150 )];
anim.values =@[v1,v2,v3,v4];
*/
UIBezierPath * path=[UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:100 startAngle:0 endAngle:2*M_PI clockwise:1];
anim.path = path.CGPath;
anim.duration = 2;
anim.repeatCount = INT_MAX; // 重复的次数
//添加动画(对谁做动画)
[self.layer addAnimation:anim forKey:nil];
}
//基础动画
-(void)testbaseAnimation{
//创建动画对象 (做什么动画)
CABasicAnimation *animation = [[CABasicAnimation alloc] init];
//怎么做动画
animation.keyPath = @"position.x";
/*animation.fromValue =@(10); 从哪
animation.toValue = @(300); 到哪
*/
//每次加10px
animation.byValue = @(10);
//不回去原来的地方
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion=NO;
//添加动画(对谁做动画)
[self.layer addAnimation:animation forKey:nil];
}
@end

// LJView.m
// 30-核心动画
//
// #import "LJView.h" @implementation LJView /*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
*/
- (void)drawRect:(CGRect)rect {
// Drawing code UIBezierPath * path=[UIBezierPath bezierPathWithArcCenter:CGPointMake(150, 150) radius:100 startAngle:0 endAngle:2*M_PI clockwise:1];
[path stroke]; } @end

IOS开发基础之核心动画 基础动画、关键帧、组动画案例的更多相关文章

  1. iOS开发UI篇—核心动画(基础动画)

    转自:http://www.cnblogs.com/wendingding/p/3801157.html 文顶顶 最怕你一生碌碌无为 还安慰自己平凡可贵 iOS开发UI篇—核心动画(基础动画) iOS ...

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

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

  3. iOS开发UI篇—核心动画(转场动画和组动画)

    转自:http://www.cnblogs.com/wendingding/p/3801454.html iOS开发UI篇—核心动画(转场动画和组动画) 一.转场动画简单介绍 CAAnimation的 ...

  4. iOS开发UI篇—核心动画(关键帧动画)

    转自:http://www.cnblogs.com/wendingding/p/3801330.html iOS开发UI篇—核心动画(关键帧动画) 一.简单介绍 是CApropertyAnimatio ...

  5. iOS开发UI篇—核心动画简介

    转自:http://www.cnblogs.com/wendingding/p/3801036.html iOS开发UI篇—核心动画简介 一.简单介绍 Core Animation,中文翻译为核心动画 ...

  6. 《iOS开发指南:从零基础到App Store上架(第2版)》

    <iOS开发指南:从零基础到App Store上架(第2版)> 基本信息 作者: 关东升 丛书名: 图灵原创 出版社:人民邮电出版社 ISBN:9787115348029 上架时间:201 ...

  7. iOS开发系列--C语言之基础知识

    概览 当前移动开发的趋势已经势不可挡,这个系列希望浅谈一下个人对IOS开发的一些见解,这个IOS系列计划从几个角度去说IOS开发: C语言 OC基础 IOS开发(iphone/ipad) Swift ...

  8. iOS开发网络篇—网络编程基础

    iOS开发网络篇—网络编程基础 一.为什么要学习网络编程 1.简单说明 在移动互联网时代,移动应用的特征有: (1)几乎所有应用都需要用到网络,比如QQ.微博.网易新闻.优酷.百度地图 (2)只有通过 ...

  9. iOS开发 - Core Animation 核心动画

    Core Animation Core Animation.中文翻译为核心动画,它是一组很强大的动画处理API,使用它能做出很炫丽的动画效果.并且往往是事半功倍. 也就是说,使用少量的代码就能够实现很 ...

  10. 2015最全iOS开发自学视频资料(基础+实战)

    最全的iOS自学视频,包括c,objective-c,UI等等,没有你找不到的,只有你学不会的,只要你想学,这里都有你所需要的. 推荐教程点这里:http://www.mobiletrain.org/ ...

随机推荐

  1. 2019-2020-1 20199318《Linux内核原理与分析》第十一周作业

    <Linux内核原理与分析> 第十一周作业 一.预备知识 什么是ShellShock? Shellshock,又称Bashdoor,是在Unix中广泛使用的Bash shell中的一个安全 ...

  2. Flink 同时按照计数和时间触发窗口计算

    自定义trigger  继承 抽象类 Trigger<T, TimeWindow> 主要实现 Trigger类的四个方法(onElement.onEventTime.onProcessin ...

  3. 关于echart折线图只有2个点时的平滑曲线问题

    问题描述: 折线图,设置平滑曲线,多个点时没有问题, 可当只有两个点(数据)的时候,这时光靠 smooth: true  就不管用了. 解决方法: 还另需设置   smoothMonotone 单调性 ...

  4. Software--电商平台--Module 5 Order & Payment

    2018-01-10  14:11:30 电商平台 订购和支付 模块 一: 整体示意图 二:构建一个框架来处理 领域模型内部发生的事情--领域事件 IDomainEvent 标识模型中的 Domain ...

  5. ratel hook app

    目录 创建平头哥项目 创建一个基本的Android项目 手动创建一个平头哥项目(windows推荐) 通过模板的方式创建平头哥项目(windows不推荐) 插入第三方集成模块 RPC调用 RPC调用静 ...

  6. HTTP相关知识学习

    五层网络模型 应用层 包括HTTP,FTP... HTTP支持客户/服务器模式 简单快速有getpost方法 灵活,可以传输任意类型 无连接,每次连接只处理一个请求,收到应答就关闭 无状态,对于事物处 ...

  7. java8 :: 双冒号传多个参数

    '::'是一种函数式接口的一种书写方法引用的方式 Kind Syntax Examples Reference to a static method ContainingClass::staticMe ...

  8. Kubernetes--用kubeadm搭建集群环境

    架构 k8s的组件架构图 OCI (Open Container Initiative) 开放容器标准.是一个轻量级,开放的治理结构(项目),在 Linux 基金会的支持下成立,致力于围绕容器格式和运 ...

  9. noi 1.1 2 输出第二个整数

    描述 输入三个整数,把第二个输入的整数输出. 输入 只有一行,共三个整数,整数之间由一个空格分隔.整数是32位有符号整数. 输出 只有一行,一个整数,即输入的第二个整数. 样例输入 123 456 7 ...

  10. Opengl数学markdown

    # opengl数学 $$\begin{Bmatrix} {A_{x}}\\ {A_{y}}\\ {A_{z}}\\ \end{Bmatrix} * \begin{Bmatrix} {B_{x}}\\ ...