Skip to content

Instantly share code, notes, and snippets.

@rockarts
Created October 5, 2018 03:54
Show Gist options
  • Save rockarts/a98974f5bb0f2055c657c2eaba9b5d08 to your computer and use it in GitHub Desktop.
Save rockarts/a98974f5bb0f2055c657c2eaba9b5d08 to your computer and use it in GitHub Desktop.
class DrawView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func draw( _ rect: CGRect) {
drawLine(x: Int(bounds.origin.x), y: Int(bounds.origin.y), width: Int(bounds.width), height: Int(bounds.height))
}
func drawLine(x:Int, y:Int, width:Int, height:Int) {
let path = UIBezierPath()
path.move(to: CGPoint(x: x, y: y))
path.addLine(to: CGPoint(x: x + width, y: y + height))
path.close()
UIColor.red.set()
path.stroke()
path.fill()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment