         pageScrollView.scrollsToTop = false
         pageScrollView.alwaysBounceVertical = false
         pageScrollView.contentInset = UIEdgeInsetsMake(0, 0, 49, 0)
-        pageScrollView.frame = CGRect(x: 0, y: segmentedBarHeight, width: size.width, height: size.height - segmentedBarHeight)
+        pageScrollView.frame = CGRect(x: 0, y: segmentedControlHeight, width: size.width, height: size.height - segmentedControlHeight)
         
         view.addSubview(pageScrollView)
     }
     
     func setUpScrollIndicator() {
-        scrollIndicator.frame.size = CGSize(width: view.bounds.width/CGFloat(viewControllers.count), height: segmentedIndicatorHeight)
+        scrollIndicator.frame.size = CGSize(width: view.bounds.width/CGFloat(viewControllers.count), height: scrollIndicatorHeight)
         scrollIndicator.frame.origin.x = 0
+        view.addSubview(scrollIndicator)
     }
 }
 

    /// Preferred height of segmented control bar.
    /// Default value is 44.
    /// If viewControllers has less than 2 items, actual height is 0.
    open var preferredSegmentedBarHeight: CGFloat = 44 {
        didSet {
            
        }
    }
    
    /// Height of segmented control bar
    /// Get only
    open var segmentedBarHeight: CGFloat {
        return viewControllers.count <= 1 ? 0 : preferredSegmentedBarHeight
    }
    
    /// Preferred of segmented indicator.
    /// Default value is 1.
    /// If viewControllers has less than 2 items, actual height is 0.
    open var perferredSegmentedIndicatorHeight: CGFloat = 2 {
        didSet {
            // Update height
            scrollIndicator.bounds.size.height = segmentedIndicatorHeight
        }
    }
    
    /// Height of segmented indicator
    /// Get only
    open var segmentedIndicatorHeight: CGFloat {
        return viewControllers.count <= 1 ? 0 : perferredSegmentedIndicatorHeight
    }
    
    var previousPageIndex : Int = 0

    
    /// scrollIndicator below the segmented control bar.
    /// Default background color is blue.
    open fileprivate(set) lazy var scrollIndicator: UIView = {
        let bar = UIView()
        bar.backgroundColor = UIColor.blue
        return bar
    }()
    
