Skip to content

Instantly share code, notes, and snippets.

@gliubc
Created September 10, 2021 03:10
Show Gist options
  • Save gliubc/8072224f32853c2d09c4570f22cdd2f4 to your computer and use it in GitHub Desktop.
Save gliubc/8072224f32853c2d09c4570f22cdd2f4 to your computer and use it in GitHub Desktop.
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
let shapeLayer = CAShapeLayer()
shapeLayer.strokeColor = UIColor(rgb: 0xEEEEEE).cgColor
shapeLayer.lineWidth = 1
// passing an array with the values [2,3] sets a dash pattern that alternates between a 2-user-space-unit-long painted segment and a 3-user-space-unit-long unpainted segment
shapeLayer.lineDashPattern = [2,3]
let path = CGMutablePath()
path.addLines(between: [CGPoint(x: 0, y: 0),
CGPoint(x: UIScreen.main.bounds.size.width - 20, y: 0)])
shapeLayer.path = path
dashView.layer.addSublayer(shapeLayer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment