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属性设置相应的路径信息即可. 以下为一个红色的小球按照指定的路径运动的动画. 此动画关键在于如 ...
随机推荐
- java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnv
转自:https://blog.csdn.net/u012941811/article/details/16960493 ava.lang.NoSuchMethodError: org.springf ...
- PHP命名空间namespace使用小结
1.介绍一下php的命名空间 什么是命名空间?从广义上来说,命名空间是一种封装事物的方法.在很多地方都可以见到这种抽象概念.例如,在操作系统中目录用来将相关文件分组,对于目录中的文件来说,它就扮演了命 ...
- 【POJ - 1661】Help Jimmy (动态规划)
Help Jimmy Descriptions: "Help Jimmy" 是在下图所示的场景上完成的游戏. 场景中包括多个长度和高度各不相同的平台.地面是最低的平台,高度为零,长 ...
- C# Web页面打印网页
<style media=print type="text/css"> .noprint{display:none} </style> 在打印时 ...
- linux自动删除30天前的日志文件
linux应用总结: 自动删除n天前的日志文件: . 使用的命令格式如下: find 对应目录 -mtime +天数 -name "文件名" -exec -rm -rf -name ...
- _bzoj1002 [FJOI2007]轮状病毒【瞎搞】
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1002 这种题真是有毒,很多叼一点的都用matrix tree定理推出了递推公式,也有一些用好 ...
- hdu 1863 畅通工程(Kruskal+并查集)
畅通工程 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- 洛谷 P1816 忠诚
https://www.luogu.org/problemnew/show/1816 st表模板 #include<cstdio> #include<algorithm> us ...
- Maven环境搭建操作记录
Maven官方网站: http://maven.apache.org/index.html Maven下载地址: http://maven.apache.org/download.cgi Maven历 ...
- html下的图片链接有边框的解决方法
使用dreamweaver创建网页后,上传到网站发现网页的图片链接有非常难看的蓝色边框,而在dw下是没有的 后来查看了一下网上的资料,发现加一个border="0"即可,默认是有边 ...