Object-C 里面的animation动画效果,核心动画
#import "CoreAnimationViewController.h"
@interface CoreAnimationViewController ()
@property(nonatomic, strong)UIView *myView;
@end
@implementation CoreAnimationViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.myView = [[UIView alloc ] initWithFrame:CGRectMake(100, 100, 100, 100)];
self.myView.backgroundColor = [UIColor cyanColor];
[self.view addSubview:_myView];
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//用于进行旋转的
CABasicAnimation *base = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
//设置持续时间
base.duration = 1;
//瞬时针旋转从**到**
base.fromValue = @0;
base.toValue = @(M_PI_2);
[self.myView.layer addAnimation:base forKey:@"base"];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//用于一系列的颜色变化
CAKeyframeAnimation *color = [CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"];
color.duration = 10;
id k1 = (id)[UIColor blueColor].CGColor;
id k2 = (id)[UIColor cyanColor].CGColor;
id k3 = (id)[UIColor magentaColor].CGColor;
id k4 = (id)[UIColor grayColor].CGColor;
color.values = @[k1, k2, k3, k4];
//添加动画
[self.myView.layer addAnimation:color forKey:@"color"];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//用于一系列的未知的变化
CAKeyframeAnimation *position = [CAKeyframeAnimation animationWithKeyPath:@"position"];
position.duration = 2;
NSValue *v1 = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
NSValue *v2 = [NSValue valueWithCGPoint:CGPointMake([UIScreen mainScreen].bounds.size.height - 100, 0)];
NSValue *v3 = [NSValue valueWithCGPoint:CGPointMake([UIScreen mainScreen].bounds.size.width - 100, [UIScreen mainScreen].bounds.size.height - 100)];
NSValue *v4 = [NSValue valueWithCGPoint:CGPointMake(0, [UIScreen mainScreen].bounds.size.height - 100)];
NSValue *v5 = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
position.values = @[v1,v2,v3,v4,v5];
position.keyTimes = @[@(0.1), @(0.4), @(0.5), @(0.8), @1];
[self.myView.layer addAnimation:position forKey:@"position"];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//动画组
//组合式的添加动画
CAAnimationGroup *group = [CAAnimationGroup animation];
group.duration = 2;
group.animations = @[color,position];
[self.myView.layer addAnimation:group forKey:@"group"];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//切换特效
CATransition *transition = [CATransition animation];
transition.duration = 2;
//切换的类型
transition.type = @"cube";
//设置子切换类型
transition.subtype = kCATransitionFromLeft;
[self.myView.layer addAnimation:transition forKey:@"transition"];
}
Object-C 里面的animation动画效果,核心动画的更多相关文章
- iOS-动画效果(首尾式动画,代码快动画,核心动画,序列帧动画)
一.各个动画的优缺点 1.首尾动画:如果只是修改空间的属性,使用首尾动画比较方便,如果在动画结束后做后续处理,就不是那么方面了. 2.核心动画:有点在于对后续的处理方便. 3.块动画: (1)在实际的 ...
- html5--6-55 动画效果-关键帧动画
html5--6-55 动画效果-关键帧动画 实例 @charset="UTF-8"; div{ width: 150px; height: 150px; font-size: 2 ...
- 用js实现动画效果核心方式
为了做好导航菜单,有时候需要在菜单下拉的时候实现动画效果,所以这几天就研究了研究如何用js实现动画效果,实现动画核心要用到两个函数,一个是setTimeOut,另一个是setInterval. 下边我 ...
- jQuery 动画效果 与 动画队列
基础效果 .hide([duration ] [,easing ] [,complete ]) 用于隐藏元素,没有参数的时候等同于直接设置 display 属性 $('.target').hide() ...
- 核心动画——Core Animation
一. CALayer (一). CALayer简单介绍 在iOS中,你能看得见摸得着的东西基本上都是UIView,比方一个button.一个文本标签.一个文本输入框.一个图标等等.这些都是UIView ...
- iOS - Core Animation 核心动画
1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...
- 安卓开发20:动画之Animation 详细使用-主要通过java代码实现动画效果
AlphaAnimation 透明效果实现: activity_main.xml中仅仅是一个简单的图片,下面的例子都会使用这个xml: <RelativeLayout xmlns:android ...
- Android动画效果之Tween Animation(补间动画)
前言: 最近公司项目下个版本迭代里面设计了很多动画效果,在以往的项目中开发中也会经常用到动画,所以在公司下个版本迭代开始之前,抽空总结一下Android动画.今天主要总结Tween Animation ...
- android Animation 动画效果介绍
Android的animation由四种类型组成 XML中 alpha 渐变透明度动画效果 scale 渐变尺寸伸缩动画效果 translate 画面转换位置移动动画效果 rotate 画面转移旋转动 ...
随机推荐
- redis bitcount variable-precision swar算法
花了不到一周的时间看完了一本reids设计与实现的书,感觉整体的设计有些地方的确很巧妙,各个结构之间联系的非常紧密,但是很简单,逻辑性的没有太多,但是学到了一个bitcount计数1的方法比较巧妙,记 ...
- ecshop开发帮助
http://www.ecshop.com/template_tutorial/ ECSHOP模板结构说明 http://help.ecshop.com/index.php ECSHOP帮助中心 ht ...
- httpClient 发送请求后解析流重用的问题(HttpEntity的重用:BufferedHttpEntity)
使用场景: 项目中使用httpClient发送一次http请求,以流的方式处理返回结果,开始发现返回的流只能使用一次,再次使用就会出错,后来看了一些解决方案,EntityUtils.consume(r ...
- 生成一个唯一token
$token = md5(uniqid(rand(), true));
- yii 输出当前的sql语句
<?php namespace app\controllers; use yii\web\Controller; use yii\data\Pagination; use app\models\ ...
- 【LeetCode】49. Group Anagrams
题目: Given an array of strings, group anagrams together. For example, given: ["eat", " ...
- 规定CSS的属性仅在IE下生效 在非IE浏览器下不生效
css中判断IE版本的语句<!--[if gte IE 6]> Only IE 6/+ <![endif]-->: 1. <!--[if !IE]> 除IE外都可识 ...
- pouchdb-find( pouchdb查询扩展插件 ,便于查询)
pouchdb-find pouchdb-find 环境搭建 下载lib bower install pouchdb-find 引入js <script src="pouchdb.js ...
- MyBatis源码解析【1】准备工作
终于迎来了这一天,我觉得现在的我在经历了长时间的学习和开发之后有了一定的经验,所以准备开始学习源码. 今天我将做好充足的准备,在接下来的一个月中,努力的爬过这座大山.(可能不用一个月,但是我觉得需要仔 ...
- NEWS-包名-baseTest-类名-ConfigManager
package baseTest; import java.io.IOException;import java.io.InputStream;import java.util.Properties; ...