从 ViewController 访问drawRect?

发布于 2025-01-05 02:03:14 字数 202 浏览 3 评论 0原文

我有一个带有 drawRect 方法的 UIView 子类。我的 viewController 使用这个子类(我只是在 xib 中设置它),因此 UIView 在屏幕上绘制了一个矩形。

现在,我想将一堆存储在我的 viewController 中的 CGRect 发送到我的 UIView drawRect 方法。

我不确定如何通过它们。有什么想法吗?谢谢。

I have a UIView subclass with a drawRect method. My viewController uses this subclass (I just set it in the xib), and so UIView draws a rectangle to the screen fine.

Now, I'd like to send a bunch CGRects stored in my viewController to my UIView drawRect method.

I'm unsure how to pass them. Any ideas? Thanks.

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

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

发布评论

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

评论(1

爱已欠费 2025-01-12 02:03:14

您可以向 UIView 子类添加属性来存储 CGRect,从 UIViewController 设置它们,然后调用 [self.view setNeedsDisplay]; 来自您的 UIViewController

You can add properties to your UIView subclass to store the CGRect's, set them from your UIViewController then call [self.view setNeedsDisplay]; from your UIViewController.

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