   private func addViews() {
     // Create subviews
     var subviews = (1...10).map { _ in addSingleView() }
+    
+    aSubview = subviews.first ?? UIView()
     
     // Create two spacer views
     subviews = createSpacerViews(subviews)

  override func preferredStatusBarStyle() -> UIStatusBarStyle {
    return UIStatusBarStyle.LightContent
  }
}


import UIKit

class ViewController: UIViewController, UIScrollViewDelegate {
  @IBOutlet weak var scrollView: UIScrollView!

  // Width of each subview relative to the scroll view width
  let subviewWidthRatio: CGFloat = 0.8
  
  // Will contain one of the subviews. It will be used for get the width of a subview
  // for calculating the scroll view offset
  var aSubview = UIView()
  
  // Will contain one of the spacers. It will be used for get the width of a subview
  // for calculating the scroll view offset.
  var aSpacer = UIView()

  override func viewDidLoad() {
    super.viewDidLoad()

    scrollView.delegate = self
    scrollView.showsHorizontalScrollIndicator = false
    
    // Makes scroll view speed close to the one in the paged scroll view mode
    scrollView.decelerationRate = UIScrollViewDecelerationRateFast

    addViews()
  }
