可可 – 我如何将NSBezierPath转换为CGPath

可可 – 我如何将NSBezierPath转换为CGPath,第1张

概述如何将NSBezierPath转换为CGPath? 谢谢。 苹果文档: Creating a CGPathRef From an NSBezierPath Object 以下是相关代码。 @implementation NSBezierPath (BezierPathQuartzUtilities)// This method works only in OS X v10.2 and later 如何将NSBezIErPath转换为CGPath?

谢谢。

解决方法 苹果文档: 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所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1039404.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存