 
 public protocol BorderDesignable {
   /**
-   `border-type`, border type
+   `bordertype: solid, dash, if not specified, solid will be used
    */
   var borderType: BorderType { get set }
 

    if borderSides.contains(.left) {
      lines.append((start: CGPoint(x: shift, y: 0), end: CGPoint(x: shift, y: bounds.size.height)))
    }

    for linePoints in lines {
      borderPath.move(to: linePoints.start)
      borderPath.addLine(to: linePoints.end)
    }

    border.path = borderPath.cgPath
    border.fillColor = UIColor.clear.cgColor
    border.strokeColor = borderColor.cgColor
    border.lineWidth = borderWidth
    border.frame = bounds
    layer.insertSublayer(border, at: 0)
  }
}

  }
}

// MARK: - Layer

fileprivate extension BorderDesignable where Self: UIView {
  func commonConfigBorder() {
    guard borderColor != nil, borderWidth > 0 else {
      return
    }

    clearLayer()
    if let mask = layer.mask as? CAShapeLayer {
      applyBorderOnMask(mask)
    } else {
      drawBorders()
    }
    configureBorderType()
  }

  private func clearLayer() {
    layer.borderColor = nil
    layer.borderWidth = 0
    layer.sublayers?.filter { $0.name == "borderSideLayer" || $0.name == "borderAllSides" }
      .forEach { $0.removeFromSuperlayer() }
  }

  private func applyBorderOnMask(_ mask: CAShapeLayer) {
    let borderLayer = CAShapeLayer()
    borderLayer.name = "borderAllSides"
    borderLayer.path = mask.path
    borderLayer.fillColor = UIColor.clear.cgColor
    borderLayer.strokeColor = borderColor!.cgColor
    borderLayer.lineWidth = borderWidth
    borderLayer.frame = bounds
    layer.insertSublayer(borderLayer, at: 0)
  }
}

// MARK: - Drawing

fileprivate extension BorderDesignable where Self: UIView {
  func drawBorders() {
    if borderSides == .AllSides {
      drawBorders()
    } else {
      drawBorderSides()
    }
  }

  // MARK: All Borders

  private func drawAllBorders() {
    layer.borderColor = borderColor!.cgColor
    layer.borderWidth = borderWidth
  }

  // MARK: Sides

  private func drawBorderSides() {
    let shapeLayer = CAShapeLayer()
    shapeLayer.name = "borderSideLayer"
    shapeLayer.path = makeBorderPath().cgPath
    shapeLayer.fillColor = UIColor.clear.cgColor
    shapeLayer.strokeColor = borderColor!.cgColor
    shapeLayer.lineWidth = borderWidth
    shapeLayer.frame = bounds
    layer.insertSublayer(shapeLayer, at: 0)
  }

  func makeBorderPath() -> UIBezierPath {
    let lines = makeLines()
    let borderPath = UIBezierPath()
    lines.forEach {
      borderPath.move(to: $0.start)
      borderPath.addLine(to: $0.end)
    }
    return borderPath
  }

  func makeLines() -> [(start: CGPoint, end: CGPoint)] {
    let shift = borderWidth / 2
    var lines = [(start: CGPoint, end: CGPoint)]()
    if borderSides.contains(.top) {
      lines.append((start: CGPoint(x: 0, y: shift), end: CGPoint(x: bounds.size.width, y: shift)))
    }
