title: Custom UIPageControl with dot images
body: <p>When I needed to custom my UIPageControl I used <a href="https://stackoverflow.com/questions/2673827/how-to-change-uipagecontrol-dots">this</a> and <a href="https://stackoverflow.com/questions/12190147/customize-dot-with-image-of-uipagecontrol-at-index-0-of-uipagecontrol">this</a> solution.</p>
  
  <p>Slightly modifying it for the new version of swift we have :</p>
  
  <pre><code>class myPageControl: UIPageControl {
      var activeImage: UIImage!
      var inactiveImage: UIImage!
  
      required init?(coder aDecoder: NSCoder) {
          super.init(coder: aDecoder)
          activeImage = UIImage(named: "active.png")!
          inactiveImage = UIImage(named: "inactive.png")!
      }
  
      func updateDots()
      {
          for i in 0 ..&lt; self.subviews.count
          {
              let dot : UIImageView = imageViewForSubview(self.subviews[i])
              if (i == self.currentPage) {
                  dot.image = activeImage
              }
              else {
                  dot.image = inactiveImage
              }
          }
      }
  
      func imageViewForSubview(view: UIView) -&gt; UIImageView {
          var dot: UIImageView? = nil
          if (view.isKindOfClass(UIView)) {
              for subview: UIView in view.subviews {
                  if (subview is UIImageView) {
                      dot = (subview as! UIImageView)
                  }
              }
              if dot == nil {
                  dot = UIImageView(frame: CGRectMake(0.0, 0.0, view.frame.size.width, view.frame.size.height))
                  view.addSubview(dot!)
              }
          }
          else {
              dot = (view as! UIImageView)
          }
          return dot!
      }
  
      func setPage(page: Int) {
          super.currentPage = page
          self.updateDots()
      }
  }
  </code></pre>
  
  <p>My problem is that I can not change the picture when you first start app.
  It only change when the page is changed.</p>
  
  <p>In <code>viewDidLoad()</code>, I added <code>setPage(0)</code> and <code>updateDots()</code>, but there is no result. What could i be doing wrong?</p>