gpt4 book ai didi

ios - CGPathCreateCopyByStrokingPath 等同于 iOS4?

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:51:25 24 4
gpt4 key购买 nike

我发现 iOS 5.0 上的 CGPathCreateCopyByStrokingPath 使用起来非常方便,但它在 iOS 5 及更高版本上可用。

有什么简单的方法可以在iOS 4上实现同路径复制吗?

最佳答案

我用的是这个,它兼容 IOS5 和 IOS4+。如果您使用相同的填充 + 描边颜色,它会 100% 有效。 Apple 的文档对此有点阴暗 - 他们说“如果你填充它就可以工作”,他们没有说“如果你抚摸它就会有点错误” - 但在那种情况下它似乎有点错误。 YMMV.

// pathFrameRange: you have to provide something "at least big enough to 
// hold the original path"

static inline CGPathRef CGPathCreateCopyByStrokingPathAllVersionsOfIOS( CGPathRef
incomingPathRef, CGSize pathFrameRange, const CGAffineTransform* transform,
CGFloat lineWidth, CGLineCap lineCap, CGLineJoin lineJoin, CGFloat miterLimit )
{
CGPathRef result;

if( CGPathCreateCopyByStrokingPath != NULL )
{
/**
REQUIRES IOS5!!!
*/
result = CGPathCreateCopyByStrokingPath( incomingPathRef, transform,
lineWidth, lineCap, lineJoin, miterLimit);
}
else
{
CGSize sizeOfContext = pathFrameRange;
UIGraphicsBeginImageContext( sizeOfContext );
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, lineWidth);
CGContextSetLineCap(c, lineCap);
CGContextSetLineJoin(c, lineJoin);
CGContextSetMiterLimit(c, miterLimit);
CGContextAddPath(c, incomingPathRef);
CGContextSetLineWidth(c, lineWidth);
CGContextReplacePathWithStrokedPath(c);
result = CGContextCopyPath(c);
UIGraphicsEndImageContext();
}
}

关于ios - CGPathCreateCopyByStrokingPath 等同于 iOS4?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7776931/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com