 
     // Add Selected Line
     // 添加选择横线
-    selectedLine = CALayer()
     selectedLine.frame = CGRect(x: appearance.tabMargin, y: appearance.tabBarHeight - 2, width: itemButtonWidth, height: 2)
     selectedLine.backgroundColor = UIColor.redColor().CGColor
     tabView.layer.addSublayer(selectedLine)

    }
  }

  private var tabView: UIView!
  private var selectedLine: CALayer!
  private var itemButtons: [UIButton] = []
  private var scrollView: UIScrollView!
  private var subViewControllers: [UIViewController] = []
  private var isDragging: Bool = false
  private var canLayoutSubviews: Bool = false

  var selectedTabIndex: Int = 0 //当前选中页 默认为0
  private var itemButtonWidth: CGFloat!

  // MARK: Initialization
  override init(frame: CGRect) {

    reset()
    canLayoutSubviews = false
    guard let dataSource = dataSource else { return }
    tabView.frame = CGRect(x: 0, y: 0, width: frame.width, height: appearance.tabBarHeight)
    addSubview(tabView)

    scrollView.frame = CGRectMake(0, appearance.tabBarHeight, frame.width, frame.height - appearance.tabBarHeight)
    scrollView.delegate = self
    scrollView.pagingEnabled = true
    scrollView.userInteractionEnabled = true
