我已经在我的iOS演示应用程序中制作了这样的圆圈。
http://www.pastebin.ca/3119326
如下图所示
I want a needle shape crossing 90 degree to line which is being made. like below image, which I am unable to find via code.
感谢。
答案 0 :(得分:-1)
伪代码/真实代码,这里是布局如何工作,只是一个快速的样本:
一行:
UIBezierPath* bezierPath = UIBezierPath.bezierPath;
[bezierPath moveToPoint: CGPointMake(43.5, 30.5)];
[bezierPath addCurveToPoint: CGPointMake(166.5, 74.5) controlPoint1: CGPointMake(166.5, 74.5) controlPoint2: CGPointMake(166.5, 74.5)];
[UIColor.blackColor setStroke];
bezierPath.lineWidth = 1;
[bezierPath stroke];
CAShapeLayer * firstNameCorners = [CAShapeLayer layer];
[firstNameCorners setPath:bezierPath];
[[self.view layer] addSublayer:firstNameCorners];
运行旋转动画:
- (void)spinUntilYouThrowUp:(CAShapeLayer*)shapeLayer duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat;
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;
[shapeLayer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}