从 ViewController 访问drawRect?
我有一个带有 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以向
UIView
子类添加属性来存储CGRect
,从UIViewController
设置它们,然后调用[self.view setNeedsDisplay];
来自您的UIViewController
。You can add properties to your
UIView
subclass to store theCGRect
's, set them from yourUIViewController
then call[self.view setNeedsDisplay];
from yourUIViewController
.