CAShapeLayer 的最大大小?

发布于 2024-09-17 07:11:49 字数 658 浏览 6 评论 0原文

我正在尝试在图像上绘制半透明形状。

我有一个 UIView ,它的图层内容设置为图像,还有一个 CAShapeLayer 子图层,其路径设置为形状。父 UIView 中有一些这样的 UIViews,它是 UIScrollView 的缩放子级。

iPhone 上一切正常,但当我在 iPad 上放大时,UIViews 变得相当大,而 CAShapeLayers 消失了。不过图像显示得很好。我猜测问题是大小问题,所以我将 CAShapeLayers 一分为二,这样就有了左侧和右侧。现在,除非用户放大得很远,例如在它们反弹之前“松开”超出我的最大变焦时,它们都会显示出来。

进一步拆分我的 CAShapeLayers 是可行的,但有点繁琐。所以,我有几个问题:

  1. CAShapeLayers 是否有最大大小限制?为什么它不适用于图层的图像内容?
  2. 为什么在 UIScrollView 内缩放时,CAShapeLayers 会重新绘制?整个缩放视图(UIScrollView的直接子视图)不应该在英寸期间被光栅化吗?我怎样才能做到这样呢?

I'm trying to draw a semi-transparent shape over an image.

I've got a UIView which has it's layer's contents set to the image, with a CAShapeLayer sub-layer who's path is set to the shape. There are a few of these UIViews inside a parent UIView, which is the zoom child of a UIScrollView.

Everything is fine on the iPhone, but when I zoom in on the iPad, the UIViews get quite large, and the CAShapeLayers disappear. The images display fine though. I guessed that the problem was a size issue, so I split the CAShapeLayers in two, so that there was a left and a right side. Now, they both get shown unless the user zooms in really far, for example while "un-pinching" beyond my maximum zoom, just before they bounce back.

Splitting up my CAShapeLayers further is doable, but a little fiddly. So, I've got a couple of questions:

  1. Is there a maximum size constraint for CAShapeLayers? Why does it not apply to the layer's image contents?
  2. Why are the CAShapeLayers re-drawing during a zoom pinch inside a UIScrollView? Shouldn't the whole zoom view (the UIScrollView's immediate child) be rasterized during the inch? How can I make it so?

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

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

发布评论

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

评论(1

咆哮 2024-09-24 07:11:49

事实证明,我的电脑(2006 款 MacBook)上的最大区域是 1024*1024。

iPad 上的全屏形状高度为 1004 像素,最大宽度约为 1044 像素,例如,如果您想要水平滚动视图中的大形状。

当双指弹跳缩放时,形状的实际高度会变大,从而将最大宽度降低至约 250 像素。这比我想要的要窄,但可行。

这在物理 iPad 上可能有所不同,但这些是我的开发盒上模拟器的限制。

It turns out that the maximum area on my computer (a 2006 MacBook) is 1024*1024.

A full screen shape on the iPad is 1004 pixels heigh, giving a maximum width of about 1044 pixels, for example if you want a large shape in a horizontal scroll view.

When pinch bounce zooming, the actual height of the shape gets larger, pushing the maximum width down to about 250 pixels. This is narrower than I'd like, but doable.

This might be different on a physical iPad, but these are the limits in the simulator on my dev box.

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