UIImageView pinch zoom swift

前端 未结 13 778
误落风尘
误落风尘 2020-11-28 04:06

I was hoping someone could help me out. I am trying to allow a user to pinch zoom on a UIImageView(with a max and min level allowed). But for some reason the it does not wor

13条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 04:57

    The option for swift 4

    class ViewController: UIViewController, UIScrollViewDelegate {
    
    @IBOutlet weak var scrolView: UIScrollView!
    @IBOutlet weak var imgPhoto: UIImageView!
    
      override func viewDidLoad() {
        super.viewDidLoad()
        scrolView.delegate = self
        scrolView.minimumZoomScale = 1.0
        scrolView.maximumZoomScale = 10.0
      }
    
      func viewForZooming(in scrollView: UIScrollView) -> UIView? {
        return imgPhoto
      }
    }
    

提交回复
热议问题