         }
     }
     
-    func addNecessarySteps() {
-        if Int(self.numberOfSteps) > self.subviews.count {
-            for index in self.subviews.count..<Int(self.numberOfSteps) {
-                let view = UIView(frame: self.stepFrameForIndex(index))
-                view.backgroundColor = self.stepsColor
-                view.alpha = 0.0
-                
-                self.addSubview(view)
-                
-                UIView.animateWithDuration(0.2, animations: { 
-                    view.alpha = 1.0
-                })
-            }
-        }
-    }
+    // MARK: Helper methods
     
+    /**
+        Calculates the frame of a step view in a given position
+     
+        - Parameter index: The position of the step view
+     
+        - Returns: The rect of the step view
+     */
     func stepFrameForIndex(index: Int) -> CGRect {
         let separationsWidth = self.stepsSeparation * CGFloat(self.numberOfSteps - 1)
         let stepsWidth = (self.frame.size.width - separationsWidth) / CGFloat(self.numberOfSteps);

        self.updateStepByStepView()
    }
    
    func updateStepByStepView() {
        if self.numberOfSteps > 0 {
            self.removeUnnecessarySteps()
            self.updateSteps()
            self.updateCurrentStep()
            self.addNecessarySteps()
        }
    }
    
    func removeUnnecessarySteps() {
        if Int(self.numberOfSteps) < self.subviews.count {
            for index in Int(self.numberOfSteps)..<self.subviews.count {
                self.subviews[Int(index)].removeFromSuperview()
            }
        }
    }
    
    func updateSteps() {
        for (index, subview) in self.subviews.enumerate() {
            if index < Int(self.numberOfSteps) {
                UIView.animateWithDuration(0.2, animations: {
                    self.subviews[Int(index)].frame = self.stepFrameForIndex(index)
                })
            } else {
                UIView.animateWithDuration(0.2, animations: {
                    subview.alpha = 0.0
                    }, completion: { (finished) in
                        subview.removeFromSuperview()
                })
            }
        }
    }
    
    func updateCurrentStep() {
        for (index, subview) in self.subviews.enumerate() {
            if index < Int(self.currentStepIndex) {


import UIKit

/// Simple and customisable stepped progress bar UI component
public class StepByStep: UIView {

    /// The current step within the total progress bar's number of steps
    public var currentStepIndex: UInt {
        didSet {
            if self.currentStepIndex > self.numberOfSteps {
