我正在创建照片拼贴应用程序。我想像Layout App
中那样调整拼贴的任何选定部分的大小The original layout when images are selected for a collage
注意:我没有使用自动版式
我使用以下代码添加了滚动视图
func addScrolls(index: Int) {
if let templatesArray = self.templates?.templates?[index - 1].scrolls {
//templatesArray contains the array of dictionary that contains coordinates of the frame
//If I get coordinates as [(x:0,y:0,width: 160,height: 160),(x:160,(x:0,y:160,height: 160)] from the templatesArray variable
for dic in templatesArray {
guard let x = dic.x else { return }
guard let y = dic.y else { return }
guard let width = dic.width else { return }
guard let height = dic.height else { return }
let frame = CGRect(x: x,y: y,width: width,height: height)
let scrollView = UIScrollView(frame: frame)
scrollView.contentSize = CGSize(width: width,height: height)
self.superFrame.addSubview(scrollView)
//superFrame has the frame (0,320,320)
let frm = CGRect(origin: CGPoint(x: 0,y: 0),size: scrollView.contentSize)
let imgView = UIImageView(frame: frm)
imgView.image = UIImage(named: self.imgArr[index])
scrollView.addSubview(imgView)
}
}
}
My collage layout after adding the above code
点击特定图像时,我添加了调整大小按钮,如下面的屏幕截图
Resize buttons added when the image is tapped
如何在拼贴布局中实现缩放功能?
谢谢!