title: Translating UIScroll and UIPageControl from Objective C to swift
body: <p>How would you write this in swift? I'm having trouble translating this because swift is my first language and this is all written in Objective C.</p>
  
  <pre><code>UIScrollView * scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
      scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 3, scrollView.frame.size.height);
      scrollView.delegate = self;
  
      UIPageControl * pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 90, scrollView.frame.size.width, 20)];
      pageControl.numberOfPages = scrollView.contentSize.width/scrollView.frame.size.width;
      [pageControl addTarget:self action:@selector(changePage:) forControlEvents:UIControlEventValueChanged];
  
  Then you need to add the following two methods:
  
  - (IBAction)changePage:(id)sender {
      CGFloat x = pageControl.currentPage * scrollView.frame.size.width;
      [scrollView setContentOffset:CGPointMake(x, 0) animated:YES];
  }
  
  -(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView  {
      NSInteger pageNumber = roundf(scrollView.contentOffset.x / (scrollView.frame.size.width));
      pageControl.currentPage = pageNumber;
  </code></pre>