Created
December 11, 2021 16:32
-
-
Save pallavtrivedi03/97582ebab8559c01a87b707c9ec3da72 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 AircraftView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
setupView() | |
} | |
required init?(coder: NSCoder) { | |
super.init(coder: coder) | |
setupView() | |
} | |
func setupView() { | |
let path: UIBezierPath = getPath() | |
let shape = CAShapeLayer() | |
shape.path = path.cgPath | |
shape.lineWidth = 2.0 | |
shape.strokeColor = UIColor.white.cgColor | |
shape.fillColor = UIColor.clear.cgColor | |
self.layer.addSublayer(shape) | |
} | |
func getPath() -> UIBezierPath { | |
let path: UIBezierPath = UIBezierPath() | |
path.move(to: CGPoint(x: 230, y: 520)) | |
path.addLine(to: CGPoint(x: 70, y: 520)) | |
path.addLine(to: CGPoint(x: 60, y: 250)) | |
path.addCurve(to: CGPoint(x: 240, y: 250), controlPoint1: CGPoint(x: 96, y: 16), controlPoint2: CGPoint(x: 204, y: 16)) | |
path.addLine(to: CGPoint(x: 230, y: 520)) | |
path.close() | |
return path | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment