加载时 UIView 视图扭曲

发布于 2024-09-25 22:54:17 字数 149 浏览 1 评论 0原文

我有一个 UIScrollView,其中包含一个 UIView,我正在使用 CGPaths 在其上绘制一个相当复杂的图形。视图加载完成后,图形会发生扭曲,因为它在水平和垂直方向上被拉长。如果我重画它,它看起来很正常。

关于造成这种情况的原因以及如何解决它有什么想法吗?

I have a UIScrollView that contains a UIView onto which I am drawing a rather complex graphic using CGPaths. After the view finishes loading the graphic is distorted in that it is elongated horizontally and vertically. If I redraw it, it looks normal.

Any ideas on what is causing this and how to fix it?

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

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

发布评论

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

评论(1

怀念你的温柔 2024-10-02 22:54:17

当您初始化 UIView 时,使用 initWithFrame 并将框架设置为绘制所有内容后的正确大小等。如果您不确定这里有一些想法:

  • 获取父视图的“边界”。
  • 在根视图上调用layoutSubviews,然后获取其框架,然后创建 UIView 并将其添加到其父视图。

When you initialise your UIView, use initWithFrame and set the frame to the correct size that it will be after everything is drawn, etc. If you are not sure here are some ideas:

  • Get the 'bounds' of the parent view.
  • Call layoutSubviews on the root view, then get its frame, then create your UIView and add it to its parent.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文