Iphone 围绕具有任意起点的圆设置视图动画
我正在尝试围绕椭圆旋转一组Calayer(旋转木马样式),如下所示:Iphone 围绕具有任意起点的圆设置视图动画,iphone,ipad,ios,core-animation,core-graphics,Iphone,Ipad,Ios,Core Animation,Core Graphics,我正在尝试围绕椭圆旋转一组Calayer(旋转木马样式),如下所示: CGMutablePathRef path = CGPathCreateMutable(); CGAffineTransform squash = CGAffineTransformMakeScale(1.1, 0.8); CGAffineTransform squashInv = CGAffineTransformInvert(squash); CGPoint c = CGPointApplyAffineTransform
CGMutablePathRef path = CGPathCreateMutable();
CGAffineTransform squash = CGAffineTransformMakeScale(1.1, 0.8);
CGAffineTransform squashInv = CGAffineTransformInvert(squash);
CGPoint c = CGPointApplyAffineTransform(centre, squashInv);
CGPathAddArc(path, &squash, c.x, c.y, radius, 2.0*M_PI, 0.0, YES);
CAKeyframeAnimation *pathAni = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAni.path = path;
pathAni.duration = 14.0;
pathAni.calculationMode = kCAAnimationPaced;
CFRelease(path);
除了每个视图总是在3点钟的位置开始设置动画外,它的效果非常好。现在,我正试着从椭圆上任意一点开始观察每个视图,希望得到一些建议
(我尝试过CGMoveArcToPoint,也尝试过在路径上使用CGAffineTransformMakeRotate旋转圆,但没有效果)
感谢您抽出时间您是否尝试了
timeOffset
属性(属于CAMediaTiming
协议的一部分)
定时协议提供了方法
在某个特定时间启动动画
持续时间内的秒数
使用两个属性:beginTime和
时间偏移。开始时间规定
输入的秒数
动画应开始的持续时间
并缩放到
动画的层。时间偏移
指定一个附加偏移量,但该偏移量为
在本地活动时间中声明。二者都
将值组合起来以确定
最终起始偏移量
那正是我想要的。谢谢