Disable vertical scroll in UIScrollView in swift?

So I have a UIScrollView ,

  var myScrollView = UIScrollView(frame:theFrame) 

and I would like to disable vertical scrolling. Does anyone know how to implement this using Swift?

+9
source share
3 answers

Try it. This sets the content size to the height of the frame, so it disables vertical scrolling because it can display the entire size.

 let scrollSize = CGSizeMake(theFrame.size.height, yourWidth) myScrollView.contentSize = scrollSize 
+5
source

Another way to do this is to set the height to 1.0

 scrollView.contentSize = CGSizeMake(theFrame.size.height, 1.0) 
+13
source
 scrDemo.contentSize = CGSize(width:(scrDemo.frame.size.width * CGFloat(imgList.count)), height: 1.0) 

in quick 4.1

0
source

Source: https://habr.com/ru/post/974012/


All Articles