iPad 版 CGPathGetPathBoundingBox() 的替代方案 (iOS 3.2)

发布于 2024-09-13 14:29:56 字数 651 浏览 3 评论 0原文

我正在尝试使用 QuartzCore 渲染半复杂的文本/渐变/图像 UITableViewCell 复合材料。值得庆幸的是,Opacity 可以让我直观地构建视图,然后吐出源代码以插入到 cocoa touch 中。问题是,Opacity 假定代码在 iOS 4 上运行,如果您想在 iPad 上绘制 Quartz 视图,这会是一个问题。

对我来说,有问题的方法是 CGPathGetPathBoundingBox ...有人介意向我指出这个(可能很简单)方法的合适替代方法或解决方法吗?

如果您想了解一些背景信息(没有双关语),请看这里:

transform = CGAffineTransformMakeRotation(1.571f);
tempPath = CGPathCreateMutable();
CGPathAddPath(tempPath, &transform, path);
pathBounds = CGPathGetPathBoundingBox(tempPath);
point = pathBounds.origin;
point2 = CGPointMake(CGRectGetMaxX(pathBounds), CGRectGetMinY(pathBounds));
transform = CGAffineTransformInvert(transform);

I'm trying to get my head around using QuartzCore to render semi-complex text/gradient/image UITableViewCell composites. Thankfully, Opacity will let me visually build the view and then spit out source code to drop in to cocoa touch. Trouble is, Opacity assumes the code is running on iOS 4, which is a problem if you want to draw Quartz views on an iPad.

For me, the offending method is CGPathGetPathBoundingBox ... would someone mind pointing me to a suitable alternative or workaround to this (presumably simple) method?

If you care to have some context (no pun intended), here you go:

transform = CGAffineTransformMakeRotation(1.571f);
tempPath = CGPathCreateMutable();
CGPathAddPath(tempPath, &transform, path);
pathBounds = CGPathGetPathBoundingBox(tempPath);
point = pathBounds.origin;
point2 = CGPointMake(CGRectGetMaxX(pathBounds), CGRectGetMinY(pathBounds));
transform = CGAffineTransformInvert(transform);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你对谁都笑 2024-09-20 14:29:57

另一种方法是 迭代路径上的点并自己​​记下锚点的最左、最右、最上和最下坐标,然后根据这些数字计算出原点和大小。

您应该将其包装在一个函数中,并将其命名为 MyPathGetPathBoundingBox 之类的名称,并使用它,直到放弃对 iOS 3.x 的支持。一旦可以,这将使您轻松切换到 CGPathGetPathBoundingBox。

The alternative is to iterate on the points of the path and note down the leftmost, rightmost, upmost, and downmost co-ordinates of the anchor points yourself, then work out origin and size from those numbers.

You should wrap this in a function, and name it something like MyPathGetPathBoundingBox, and use that until you drop support for iOS 3.x. That will make it easy to switch to CGPathGetPathBoundingBox once you can.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文