第三十八篇:CAKeyframeAnimation--+CAShapeLayer+UIBezierPath用法,关键帧动画

本文主要是介绍第三十八篇:CAKeyframeAnimation--+CAShapeLayer+UIBezierPath用法,关键帧动画,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!



有个很关键的属性:rotationMode

// rotationMode设置=kCAAnimationRotateAuto根据曲线的切线自动旋转

    keyframeAnimation.rotationMode =kCAAnimationRotateAuto ;

//
//  ViewController.m
//  CAKeyframeAnimation--+CAShapeLayer+UIBezierPath用法
//
//  Created by 瞿杰 on 2017/3/24.
//  Copyright © 2017年 yiniu. All rights reserved.
//#import "ViewController.h"@interface ViewController ()@property (nonatomic , strong) UIView * contentView ;@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width ;CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height ;self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,screenWidth , screenHeight)];self.contentView.backgroundColor = [UIColor blackColor];[self.view addSubview:self.contentView];UIBezierPath * bezierPath = [UIBezierPath bezierPath];[bezierPath moveToPoint:CGPointMake(0, 150)];[bezierPath addCurveToPoint:CGPointMake(300, 150) controlPoint1:CGPointMake(300.0*1/4, 0) controlPoint2:CGPointMake(300.0*3/4, 300)];CAShapeLayer * shapeLayer = [CAShapeLayer layer];shapeLayer.path = bezierPath.CGPath ;shapeLayer.lineWidth = 3.0 ;
//    shapeLayer.backgroundColor = [UIColor grayColor].CGColor ;shapeLayer.fillColor = [UIColor blueColor].CGColor ;shapeLayer.strokeColor = [UIColor redColor].CGColor ;[self.contentView.layer addSublayer:shapeLayer];// 添加一个滑动的图层CALayer * slipLayer = [CALayer layer];slipLayer.frame = CGRectMake(0, 0, 50, 50);slipLayer.position = CGPointMake(0, 150);slipLayer.contents = (__bridge id)[UIImage imageNamed:@"icon_tmpImageName"].CGImage ;slipLayer.affineTransform = CGAffineTransformRotate(CGAffineTransformIdentity, M_PI_4);[self.contentView.layer addSublayer:slipLayer];// 根据position创建一个(图层的中心点)关建帧动画,CAKeyframeAnimation * keyframeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];keyframeAnimation.duration = 4.0 ;keyframeAnimation.path = bezierPath.CGPath ;keyframeAnimation.repeatCount = 100 ;// 把rotationMode设置=kCAAnimationRotateAuto 根据曲线的切线自动旋转keyframeAnimation.rotationMode = kCAAnimationRotateAuto ;// slipLayer 添加一个动画[slipLayer addAnimation:keyframeAnimation forKey:nil];}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}@end


这篇关于第三十八篇:CAKeyframeAnimation--+CAShapeLayer+UIBezierPath用法,关键帧动画的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/983615

相关文章

#error用法

/* *检查编译此源文件的编译器是不是C++编译器 *如果使用的是C语言编译器则执行#error命令 *如果使用的是 C++ 编译器则跳过#error命令 */ #ifndef __cplusplus #error 亲,您当前使用的不是C++编译器噢! #endif #include <stdio.h> int main() {

SQL Server中,isnull()函数以及null的用法

SQL Serve中的isnull()函数:          isnull(value1,value2)         1、value1与value2的数据类型必须一致。         2、如果value1的值不为null,结果返回value1。         3、如果value1为null,结果返回vaule2的值。vaule2是你设定的值。        如

tensorboard-----summary用法总结

Tensorflow学习笔记——Summary用法         最近在研究tensorflow自带的例程speech_command,顺便学习tensorflow的一些基本用法。 其中tensorboard 作为一款可视化神器,可以说是学习tensorflow时模型训练以及参数可视化的法宝。 而在训练过程中,主要用到了tf.summary()的各类方法,能够保存训练过程以及参数分布图并在

vscode-创建vue3项目-修改暗黑主题-常见错误-element插件标签-用法涉及问题

文章目录 1.vscode创建运行编译vue3项目2.添加项目资源3.添加element-plus元素4.修改为暗黑主题4.1.在main.js主文件中引入暗黑样式4.2.添加自定义样式文件4.3.html页面html标签添加样式 5.常见错误5.1.未使用变量5.2.关闭typescript检查5.3.调试器支持5.4.允许未到达代码和未定义代码 6.element常用标签6.1.下拉列表

YTKKeyValueStore用法

iOS端的尝试 后来我从后台转做iOS端的开发,我就尝试了在iOS端直接使用Key-Value式的存储。经过在粉笔网、猿题库、小猿搜题三个客户端中的尝试后,我发现Key-Value式的存储不但完全能够满足大多数移动端开发的需求,而且非常适合移动端采用。主要原因是:移动端存储的数据量不会很大: 如果是单机的应用(例如效率工具Clear),用户自己一个人创建的数据最多也就上万条。 如果

redis高级用法

redis 慢日志查询 配置参数 slowlog-log-slower-than 10000 #单位微秒 slowlog-max-len 选项指定服务器最多保存多少条慢查询日志 redis-cli slowlog get #获取慢日志1) 1) (integer) 4 # 日志的唯一标识符(uid)2) (integer) 1378781447 # 命令执

Log4j用法

日志是应用软件中不可缺少的部分,Apache的开源项目Log4j是一个功能强大的日志组件,提供方便的日志记录,具体请参考Log4j文档指南。 Log4j下载 在apache网站,可以免费下载到Log4j最新版本的软件包 Apache log4j  (推荐) Apache log4j 2 Log4j的包下载完成后,解压,将其中打包好的的log4j-1.x.x.jar导入你的工程

sql之top用法

TOP 子句 TOP 子句用于规定要返回的记录的数目。 对于拥有数千条记录的大型表来说,TOP 子句是非常有用的。 注释: 并非所有的数据库系统都支持 TOP 子句。 SQL Server 的语法: SELECT TOP number|percent column_name(s)FROM table_name MySQL 和 Oracle 中的 SQL SELECT TOP 是等价的 M

ArkTS开发系列之导航 (2.7动画)

上篇回顾: ArkTS开发系列之导航 (2.6 图形) 本篇内容:动画的学习使用 一、 知识储备 1. 布局更新动画 包含显式动画(animateTo)和属性动画(animation) 动画类型名称特点显式动画闭包内的变化都会触发动画执行, 可以做较复杂的动画属性动画属性变化时触发动画执行, 设置简单 说白了,显示动画就是靠闭包事件触发,属性动画是挂在组件身上的属性变化触发 显式动画

Android 扇形网络控件 - 无网络视图(动画)

前言 一般在APP没有网络的情况下,我们都会用一个无网络的提示图标,在提示方面为了统一app的情况,我们一般使用简单的提示图标,偶尔只需要改变一下图标的颜色就一举两得,而不需要让PS来换一次颜色。当然app有图标特殊要求的就另当别论了。 效果图 当你第一眼看到这样的图,二话不说直接让UI给你切一张图标来的快对吧,我其实开始也是这么想的,但是到了做的app越来越多的时候,你就会发现就算是用