在iOS中拆分UIImageView(Splitting UIImageView in iOS)

编程入门 行业动态 更新时间:2024-10-25 06:27:07
iOS中拆分UIImageView(Splitting UIImageView in iOS)

我在iOS上制作照片拼贴应用程序。 照片的最大数量为12.拍摄照片后,我将它们以网格方式排列在不同的帧中(如PicCollage中)。

现在我想添加一个功能,用户可以通过该功能操作帧的边缘。 它们可以一次触摸并使任何特定的图像视图变大或变小(类似于SplitPic中使用的概念)。 我不知道该怎么做。 我可以手动保持跟踪帧的所有边缘,然后在触摸移动中递增/递减x,y,宽度,高度,但这是正确的方法吗?

I am making a photo collage app in iOS. The maximum number of photos is 12. After taking the photos I am arranging them in different frames in a grid fashion (like in PicCollage).

Now I want to add a feature by which the user can manipulate the edges of the frames. They can touch and make any particular imageview bigger or smaller one at a time (similar to the concept used in SplitPic). I am getting no idea about how to do this. I can manually keep a track of all the edges of the frames and then increment / decrement the x, y, width, height incrementally in touch move but is this the right approach ?

最满意答案

使用附加到每个UIImageViews的UIPanGestureRecognizer,并在其方法中进行必要的框架更改。 网上有很多关于此的教程。

您不需要“手动跟踪帧” - 只要它们显示在屏幕上(附加到显示的某个超级视图),它们将保留这些值以供您检查/修改。

Use a UIPanGestureRecognizer attached to each of your UIImageViews and do the necessary frame changes in it's methods. There's a ton of tutorials on the web for this.

You don't need to "manually keep track of the frames" - as long as they're displayed on screen (attached to some superview that is displayed), they will keep those values for you to inspect/modify.

更多推荐

本文发布于:2023-07-26 17:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1278905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:iOS   UIImageView   Splitting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!