如何将 x 个 UIImages 连接在一起?

发布于 2024-08-17 10:48:12 字数 139 浏览 3 评论 0原文

我希望将一些图像拼接在一起,这些图像始终添加到前一个图像的底部。

例如,我有图像 A、B 和 C。我希望它们彼此重叠,例如:

A
B
C

最好的方法是什么?

谢谢!

I'm looking to stitch some images together, with the images always being added to the bottom of the previous image.

e.g. I have images A,B and C. I would like them to appear on top of one another like:

A
B
C

What's the best way to do this?

Thanks!

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

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

发布评论

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

评论(2

尘世孤行 2024-08-24 10:48:12

我最后这样做了:

+ (UIImage *)joinImages:(UIImage *)im1 secondImage:(UIImage *)im2 thirdImage:(UIImage *)im3
{
//Joins 3 UIImages together, stitching them vertically
CGSize size = CGSizeMake(320, 480);
UIGraphicsBeginImageContext(size);

CGPoint image1Point = CGPointMake(0, 0);
[im1 drawAtPoint:image1Point];

CGPoint image2Point = CGPointMake(0, im1.size.height);
[im2 drawAtPoint:image2Point];

CGPoint image3Point = CGPointMake(0, im1.size.height +im2.size.height);
[im3 drawAtPoint:image3Point];

UIImage* finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return finalImage;
}

I did this in the end:

+ (UIImage *)joinImages:(UIImage *)im1 secondImage:(UIImage *)im2 thirdImage:(UIImage *)im3
{
//Joins 3 UIImages together, stitching them vertically
CGSize size = CGSizeMake(320, 480);
UIGraphicsBeginImageContext(size);

CGPoint image1Point = CGPointMake(0, 0);
[im1 drawAtPoint:image1Point];

CGPoint image2Point = CGPointMake(0, im1.size.height);
[im2 drawAtPoint:image2Point];

CGPoint image3Point = CGPointMake(0, im1.size.height +im2.size.height);
[im3 drawAtPoint:image3Point];

UIImage* finalImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return finalImage;
}
黑色毁心梦 2024-08-24 10:48:12

创建一个 UIView,然后添加多个 UIImageView 实例作为子视图。为每个子视图设置图像,一切就完成了。如果您有一组固定的图像(或至少有固定数量),则可以在 InterfaceBuilder 中完成所有布局。否则,只需创建一个新的 UIImageView,然后在父视图上调用 addSubView: 即可。

http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/addSubview

如果设置图像将比屏幕高,您将需要使用 UITableView。

Create a UIView, then add multiple UIImageView instances as subviews. Set the image for each subview, and you're all set. If you have a fixed set of images (or at least a fixed number), you can do all of the layout in InterfaceBuilder. Otherwise, it's just a matter of creating a new UIImageView, then calling addSubView: on the parent view.

http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/addSubview:

If the set of images will be taller than the screen, you'll want to use a UITableView.

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