My code below should draw a x and y line just a graph plaine but no line are appearing. I just dont know why they are not appearing.
import UIKit
class ViewController: UIViewController{
var box = Line()
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(box)
box.drawLine()}
}
class Line:UIView {
var line = UIBezierPath() var line2 = UIBezierPath() func drawLine() { line.move(to: CGPoint(x: 0, y: bounds.height / 2)) line.addLine(to: CGPoint(x: (bounds.width) , y: bounds.height / 2)) UIColor.black.setStroke() line.lineWidth = 0.1 line.stroke() line2.move(to: CGPoint(x: bounds.width / 2, y:0 )) line2.addLine(to: CGPoint(x: (bounds.width / 2) , y: (bounds.height) )) UIColor.black.setStroke() line2.lineWidth = 0.1 line2.stroke() } override func draw(_ rect: CGRect) { drawLine() }
}