Created
October 5, 2018 03:54
-
-
Save rockarts/a98974f5bb0f2055c657c2eaba9b5d08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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