CGPathAddArc
- float angle = 360 / 6;
- for (int i = 0; i < 6; i++) {
- UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- float offsetAngle = angle * i;
- button.bounds = CGRectMake(0, 0, 32, 32);
- button.center = CGPointMake(cos(offsetAngle * RADIANS) * 160, sin(offsetAngle * RADIANS) * 160);
- button.tag = i;
- CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
- CGMutablePathRef path = CGPathCreateMutable();
- pathAnimation.calculationMode = kCAAnimationPaced;
- pathAnimation.fillMode = kCAFillModeForwards;
- pathAnimation.removedOnCompletion = NO;
- pathAnimation.duration = 2;
- CGPathMoveToPoint(path, NULL, button.center.x, button.center.y);
- CGPathAddArc(path, NULL, 0, 0, 160, offsetAngle * M_PI/180, offsetAngle * M_PI/180 + M_PI, YES);
- pathAnimation.path = path;
- CGPathRelease(path);
- [button.layer addAnimation:pathAnimation forKey:@"curve"];
- [tabBarView addSubview:button];
- }
因为只是Layer的内容发生的位置变化,其实UIView还是在原来的位置上,如果需要使用应该在Animation结束后重新设定UIView的位置.
顺便翻译一下原文:
CGPathAddArc (
CGMutablePathRef path,
const CGAffineTransform *m,
CGFloat x,
CGFloat y,
CGFloat radius,
CGFloat startAngle,
CGFloat endAngle,
bool clockwise
);
path:动画的路径;
m:layer的transform;
x:其实x和y是什么我还没弄明白,根据原文应该是弧的圆心点,但我设置过,这更像是偏移量;
y:同上;
startAngle:起始的角度点,零度是与x轴相交点,度数为顺时针;
endAngle:结束的角度点;
clockwis:是否顺时针.
CGPathAddArc的更多相关文章
- iOS绘制收益柱状图
项目需求,参考了其他绘图demo,自己绘制出来了,不过代码改得有点乱,添加了很多变量,时间关系没用太合适的命名,逻辑处理也没进行优化. 看看效果图(虚线区域都是画的,其他区域添加的都是控件),附上源码 ...
- iOS CoreAnimation详解(一) 有关Layer的动画
以前由于项目需要 也写了一些动画 ,但是知识不系统,很散.这段时间趁着项目完成的空袭,来跟着大神的脚步系统的总结一下iOS中Core Animation的知识点. 原博客地址:http://blog. ...
- iOS CALayer应用详解(2)
参考博客:http://blog.csdn.net/hello_hwc?viewmode=list 如果你对CALayer 还没有一个清晰的理解,欢迎看一下前面的博客: http://www.cnbl ...
- iOS开发CoreGraphics核心图形框架之一——CGPath的应用
一.引言 CoreGraphics核心图形框架相较于UIKit框架更加偏于底层.在Objective-C工程中,CoreGraphics其中方法都是采用C语言风格进行编写的,同时其并不支持Obj ...
- Quartz2D 编程指南(一)概览、图形上下文、路径、颜色与颜色空间
概览 图形上下文 路径 颜色与颜色空间 变换 图案 阴影 渐变 透明层 Quartz 2D 中的数据管理 位图与图像遮罩 CoreGraphics 绘制 Layer 0.说明 本篇博客主要是对官方文档 ...
- Paths_Quartz2D
Paths中的几个重要元素 Points void CGContextMoveToPoint ( CGContextRef c, CGFloat x, CGFloat y ); 指定 ...
- ArrowLayer : A coustom layer animation
Since my other answer (animating two levels of masks) has some graphics glitches, I decided to try r ...
- Paths(转载)
Paths中的几个重要元素 Points void CGContextMoveToPoint ( CGContextRef c, CGFloat x, CGFloat y ); 指定一个点成为curr ...
- 用CAKeyframeAnimation构建动画路径
复杂路径的动画,我们可以借助关键关键帧动画(CAKeyframeAnimation)来实现,给其的path属性设置相应的路径信息即可. 以下为一个红色的小球按照指定的路径运动的动画. 此动画关键在于如 ...
随机推荐
- hdu 1719
Friend Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- 使用Asp.net Identity 创建用户 、登录代码
1.Identity 1中的注册.登录.注销代码 vs 2013中自带的注册用户代码: 1.首先创建一个ApplicationUser 初始化用户名. 2.使用UserManager创建一个用户,用使 ...
- 使用java发送HTTP请求
public class Test { public static void main(String[] args) { BufferedReader in = null; String result ...
- 解决 The word is not correctly spelled问题(转载)
转自:http://jyao.iteye.com/blog/1261555 The word is not correctly spelled 此问题是eclipse校验单词拼写造成,如果出在配置文件 ...
- svn报错:privious operation has not finshed;run 'cleanup' if it was interrupted
在更新svn的过程中,可能中途会取消,取消之后再次更新时可能提示,如下图: 下载sqlite3工具,进入此下载地址:https://www.sqlite.org/download.html 将sqli ...
- bzoj 1150: [CTSC2007]数据备份Backup【链表+堆】
参考:http://blog.csdn.net/Regina8023/article/details/44158947 神奇的做法.题意相当于若干个数取不相邻的k个使最小.先把数组差分,len表示这段 ...
- P4055 [JSOI2009]游戏
传送门 把这个图给黑白染色然后建二分图,如果有完备匹配那么就gg,否则放在所有的非匹配点都可以 简单来说的话就是放在非匹配点,那么对手的下一步必定移到一个匹配点,然后自己可以把它移到这个匹配点所匹配的 ...
- CF915E Physical Education Lessons(珂朵莉树)
中文题面 据说正解是动态开点线段树而且标记也不难下传的样子 然而这种区间推平的题目还是喜欢写珂朵莉树啊……码量小…… 虽然真要构造的话随便卡…… //minamoto #include<cstd ...
- 使用vmware12安装Ubuntu 遇到的两个问题和解决
1.need the x86-64 cpu,but only detected the xxx cpu. 这是因为bios中的virtual function 是 disabled,改为enabled ...
- float(double)快速转换int的方法
自己写一个软件渲染器的时候,无意中发现float转换int非常耗时,于是查阅文章,这才有了这个命题,以前不清楚还有这么个机制.网上看了很多文章,搜索到了一个数字6755399441055744,这个是 ...