在以编程方式添加的子视图中绘制?

发布于 2024-10-08 10:49:36 字数 196 浏览 0 评论 0原文

我有一个 UIScrollView 以编程方式添加到 UIView 中。 我想在 UIScrollView 本身上绘制一些图像。 我知道如何使用以下命令在主视图中绘制:

[image drawInRect...];

但我只是不明白如何在子视图中执行此操作? 我填写我并不真正理解上下文是什么以及如何到达它?

感谢您的帮助。 沙尼

I have a UIScrollView added programmatically to a UIView.
I want to draw few images to the UIScrollView itself.
I know how to draw in the main view using:

[image drawInRect....];

but I just can not understand how to do it inside of a sub view?
i fill that I don't truly understand what is the context and how do i reach it?

thanks for any help.
shani

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

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

发布评论

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

评论(2

无声无音无过去 2024-10-15 10:49:36

如果您询问如何将图像添加到以编程方式添加的 uiscrollview 中,那么这很简单。

将图像添加到 UIImageView,然后使用 addSubview: 方法将该 Imageview 添加到滚动视图。

[scrollView addSubview:imageView];

If you are asking how to add an image to a uiscrollview which has been added programatically then it is simple.

Add the image to a UIImageView then add that Imageview to the scroll view using addSubview: method.

[scrollView addSubview:imageView];
天涯离梦残月幽梦 2024-10-15 10:49:36

好吧,如果有人想知道的话——
解决方案是将图像绘制到 UIScrollView 的图层上。
如果不对其进行子类化,则无法绘制视图本身。

Well if any one wants to know -
the solution is to draw the images to the layer of the UIScrollView.
you can not draw to the view itself without sub classing it.

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