Wednesday, November 30, 2022
HomeiOS Developmentios - Can't Scroll Left or proper aspect of UIImageView in UIScrollView...

ios – Can’t Scroll Left or proper aspect of UIImageView in UIScrollView – Swift

I’ve a view inside a scrollview which incorporates imageview. Utilizing the viewForZooming making an attempt to zoom in and zoom out performance for the picture view. I can zoom in and zoom out the picture. Nevertheless, I’ve hassle in scrolling left aspect or proper aspect of the picture after zooming in.

My Primary (Base) seems like,

[! [Main Base Hierarchy here] (] (

My Code,

@IBOutlet weak var scrollView: UIScrollView!

In ViewDidLoad(),

scrollView.maximumZoomScale = 4
scrollView.minimumZoomScale = 1
scrollView.contentSize = Img.body.measurement
scrollView.delegate = self

My extension code,

extension CardsViewController: UIScrollViewDelegate{
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
   let trailingSpace: CGFloat = 10
   UIView.animate(withDuration: 1.0, delay: 0.0, choices: [], animations: {
      let screenSize = UIScreen.essential.bounds.measurement
      let x = screenSize.width - self.cardbgView.body.measurement.width - trailingSpace
      let y = self.cardbgView.body.origin.y
      self.cardbgView.body = 
      CGRect(x: x, y: y, width: self.cardbgView.body.measurement.width, peak:self.cardbgView.body.measurement.peak)
   return cardbgView

What I’m making an attempt to attain right here is to zoom within the picture and scroll left aspect and proper aspect in addition to transfer the zoomed picture all sides to view/learn the picture



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments