相关疑难解决方法(0)

iPhone核心动画 - 画一个圆圈

我想创建一个动画.我可以解释这个问题的最佳方法是,如果你能想象画一个圆圈.它从顶部或12点钟开始,顺时针顺时针绘制,直到它在10秒左右的空间内变成一个完整的圆圈.

我得到的壁橱是使用Core Animation绘制一个围绕中心点旋转的点(使用此处的示例代码).但我对如何绘制圆圈感到茫然?任何建议都非常欢迎.

非常感谢 :)

iphone core-animation

48
推荐指数
2
解决办法
5万
查看次数

iOS核心动画:旋转的锚点不正确

我想在iOS中实现基本旋转动画,其中视图围绕其中心点连续旋转.

但是,由于某种原因,旋转的锚点始终是父视图的原点,而不是旋转视图的中心.
因此,即使我手动设置锚点,视图也会围绕屏幕的左上角旋转.

这是我正在做的事情:

// Add shape layer to view
CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
CGRect shapeRect = CGRectMake(0, 0, 100, 100);
UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:shapeRect cornerRadius:5];
shapeLayer.path = roundedRect.CGPath;
shapeLayer.anchorPoint = CGPointMake(0.5, 0.5);
shapeLayer.fillColor = [[UIColor redColor] CGColor];

[self.view.layer addSublayer:shapeLayer];

// Set rotation animation
CATransform3D rotationTransform = CATransform3DMakeRotation(M_PI, 0, 0, 1);
CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
rotationAnimation.toValue = [NSValue valueWithCATransform3D:rotationTransform];
rotationAnimation.duration = 1.0f;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = HUGE_VALF;

[shapeLayer addAnimation:rotationAnimation forKey:@"transform"];
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

core-animation uiview ios

5
推荐指数
1
解决办法
6099
查看次数

标签 统计

core-animation ×2

ios ×1

iphone ×1

uiview ×1