Iphone UIView中的BezierPath旋转
我正在触摸事件上绘制BezierPath。现在我必须使用手势方法在同一位置旋转贝塞尔路径。但问题是,在旋转之后,它的位置变了。如下图所示。。我怎样才能解决这个问题 上面的图像是原始图像。 与我分享你的想法。。 提前感谢请登记Iphone UIView中的BezierPath旋转,iphone,ios,uigesturerecognizer,bezier,uibezierpath,Iphone,Ios,Uigesturerecognizer,Bezier,Uibezierpath,我正在触摸事件上绘制BezierPath。现在我必须使用手势方法在同一位置旋转贝塞尔路径。但问题是,在旋转之后,它的位置变了。如下图所示。。我怎样才能解决这个问题 上面的图像是原始图像。 与我分享你的想法。。 提前感谢请登记 applyTransform: 使用指定的仿射变换矩阵变换路径中的所有点 - (void)applyTransform:(CGAffineTransform)transform 我还没试过这个。但下面是如何从链接旋转NSBezierPath。尝试在UIBezierPat
applyTransform:
使用指定的仿射变换矩阵变换路径中的所有点
- (void)applyTransform:(CGAffineTransform)transform
我还没试过这个。但下面是如何从链接旋转NSBezierPath
。尝试在UIBezierPath
上使用类似的方法
- (NSBezierPath*)rotatedPath:(CGFloat)angle aboutPoint:(NSPoint)cp
{
// return a rotated copy of the receiver. The origin is taken as point <cp> relative to the original path.
// angle is a value in radians
if( angle == 0.0 )
return self;
else
{
NSBezierPath* copy = [self copy];
NSAffineTransform* xfm = RotationTransform( angle, cp );
[copy transformUsingAffineTransform:xfm];
return [copy autorelease];
}
}
教程的链接已失效
NSAffineTransform *RotationTransform(const CGFloat angle, const NSPoint cp)
{
// return a transform that will cause a rotation about the point given at the angle given
NSAffineTransform* xfm = [NSAffineTransform transform];
[xfm translateXBy:cp.x yBy:cp.y];
[xfm rotateByRadians:angle];
[xfm translateXBy:-cp.x yBy:-cp.y];
return xfm;
}