在 UIImageView 中的多个位置绘制 UIImage

发布于 2024-08-08 15:44:54 字数 122 浏览 3 评论 0原文

我有点迷失在 UIImage、UIImageView、CG、图层之间...... 我想在同一个 UIImageView 中多次绘制同一个 UIImage。我不想为每个对象都有一个单独的子视图。有一个平面图像就足够了。我该怎么做?

I'm kind of lost in between UIImage, UIImageView, CG, layers...
I want to draw the same UIImage multiple times in the same UIImageView. I don't want to have a separate subview for each of those objects. It's enough to have a flat image. How do I do that?

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

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

发布评论

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

评论(4

背叛残局 2024-08-15 15:44:54

我发现这个是因为我也在寻找这个问题的答案

http://www .cocoanetics.com/2010/07/drawing-on-uiimages/

i found this as i was also looking for answers to this question

http://www.cocoanetics.com/2010/07/drawing-on-uiimages/

毅然前行 2024-08-15 15:44:54

UIImageView 不允许你这样做。相反,我建议您使用常规 UIView 并使用 drawRect: 函数来绘制图像。如果您想知道如何做到这一点,请查看 Core Graphics 文档。

UIImageView does not allow you to do that. Instead, I would recommend you to use a regular UIView and use the drawRect: function to draw the images. Take a look at the Core Graphics docs if you want to know how to do that.

↙厌世 2024-08-15 15:44:54

您必须创建多个 UIImage 对象才能执行此操作。实际上 UIImageView 是错误的选择。创建一个 UIView 并向其添加多个 UIImageView 对象。对不起。

You'll have to create multiple UIImage objects to do this. Really a UIImageView is the wrong choice. Create a UIView and just add mulitple UIImageView objects to it. Sorry.

浅唱ヾ落雨殇 2024-08-15 15:44:54

嗯,我想这很简单,

[imageView addSubview:myTextView];

可以使用以下代码来制作 myTextView

UIImage *myImage = [[uiimage alloc]initwithname:@"txtImage"];
UIImageView *myTextView =
      [[UIImageView alloc]initwithframe:("enter the height width you want ")];

Well I guess it is simple

[imageView addSubview:myTextView];

where myTextView can be made using the following piece of code

UIImage *myImage = [[uiimage alloc]initwithname:@"txtImage"];
UIImageView *myTextView =
      [[UIImageView alloc]initwithframe:("enter the height width you want ")];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文