我如何缩放图像数组?现在我可以将图像缩放为.gif
我的代码:
class ScrollImageViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var scrollImage: UIScrollView!
private var imageView: UIImageView!
var imagesArray = [String]()
override func viewDidLoad() {
super.viewDidLoad()
self.scrollImage.minimumZoomScale = 1.0
self.scrollImage.maximumZoomScale = 5.0
for i in 0..<imagesArray.count {
imageView = UIImageView()
imageView.sd_setImage(with: URL(string: imagesArray[i]))
imageView.contentMode = .scaleAspectFit
let xPosition = self.view.frame.width * CGFloat(i)
imageView.frame = CGRect(x: xPosition, y: 0, width: self.scrollImage.frame.width, height: self.scrollImage.frame.height)
scrollImage.contentSize.width = scrollImage.frame.width * CGFloat(i + 1)
scrollImage.addSubview(imageView)
}
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return imageView
}
}
我试过了raywenderlich的课,但他们没有帮助我:(
我希望获得像AirBnB或示例的结果:
滚动一次然后放大,缩小,滚动两次 - 放大,缩小等等
答案 0 :(得分:0)
您可以查看以下框架
https://github.com/zvonicek/ImageSlideshow
它有一个FullScreenSlideshowViewController
类,可用于您的目的,也可以自定义。