title: Custom paging for UIScrollView
body: <p>I have a UIScrollView that scrolls horizontally with paging enabled. Is there any way to change the paging of the scrollview so that it snaps half way through the entire length of the scroll view. I've added pictures that show what i'm looking for.</p>
  
  <p><a href="https://i.stack.imgur.com/CPogy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CPogy.png" alt="Page 1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/kHAEJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kHAEJ.png" alt="Page 2"></a></p>
  
  <p><a href="https://i.stack.imgur.com/LY4Ag.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LY4Ag.png" alt="Page 3"></a></p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
  
  
  let scrollView = UIScrollView()
  scrollView.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height)
  scrollView.contentSize = CGSize(width: self.view.frame.size.width * 2, height: self.view.frame.size.height)
  scrollView.isPagingEnabled = true
  self.view.addSubview(scrollView)
  
  let view1 = UIView()
  view1.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width / 2, height: self.view.frame.size.height)
  view1.backgroundColor = UIColor.purple
  scrollView.addSubview(view1)
  
  let view2 = UIView()
  view2.frame = CGRect(x: self.view.frame.size.width / 2, y: 0, width: self.view.frame.size.width / 2, height: self.view.frame.size.height)
  view2.backgroundColor = UIColor.green
  scrollView.addSubview(view2)
  
  let view3 = UIView()
  view3.frame = CGRect(x: self.view.frame.size.width, y: 0, width: self.view.frame.size.width / 2, height: self.view.frame.size.height)
  view3.backgroundColor = UIColor.yellow
  scrollView.addSubview(view3)
  
  let view4 = UIView()
  view4.frame = CGRect(x: self.view.frame.size.width + self.view.frame.size.width / 2, y: 0, width: self.view.frame.size.width / 2, height: self.view.frame.size.height)
  view4.backgroundColor = UIColor.red
  scrollView.addSubview(view4)
  
  }
  </code></pre>