谢谢。
解决方法 苹果文档: Creating a CGPathRef From an NSBezierPath Object以下是相关代码。
@implementation NSBezIErPath (BezIErPathQuartzUtilitIEs)// This method works only in OS X v10.2 and later.- (CGPathref)quartzPath{ int i,numElements; // Need to begin a path here. CGPathref immutablePath = NulL; // Then draw the path elements. numElements = [self elementCount]; if (numElements > 0) { CGMutablePathref path = CGPathCreateMutable(); NSPoint points[3]; BOol dIDClosePath = YES; for (i = 0; i < numElements; i++) { switch ([self elementAtIndex:i associatedPoints:points]) { case NSMovetoBezIErpathelement: CGPathMovetoPoint(path,NulL,points[0].x,points[0].y); break; case NSlinetoBezIErpathelement: CGPathAddlinetoPoint(path,points[0].y); dIDClosePath = NO; break; case NSCurvetoBezIErpathelement: CGPathAddCurvetoPoint(path,points[0].y,points[1].x,points[1].y,points[2].x,points[2].y); dIDClosePath = NO; break; case NSClosePathBezIErpathelement: CGPathCloseSubpath(path); dIDClosePath = YES; break; } } // Be sure the path is closed or Quartz may not do valID hit detection. if (!dIDClosePath) CGPathCloseSubpath(path); immutablePath = CGPathCreatecopy(path); CGPathRelease(path); } return immutablePath;}@end总结
以上是内存溢出为你收集整理的可可 – 我如何将NSBezierPath转换为CGPath全部内容,希望文章能够帮你解决可可 – 我如何将NSBezierPath转换为CGPath所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)