I have made a greenView:
static func createRectView(
x: Float,
y: Float,
width: Float,
height: Float,
color: UIColor,
transparency: Float
) -> UIView {
let viewRectFrame = CGRect(
x: CGFloat(x),
y: CGFloat(y),
width: CGFloat(width),
height: CGFloat(height)
)
let retView = UIView(frame:viewRectFrame)
retView.backgroundColor = color
retView.alpha = CGFloat(transparency)
return retView
}
let greenView: UIView = createRectView(
x: 50,
y: 110,
width: 150,
height: 100,
color: .green,
transparency: 1
)
view.addSubview(greenView)
I have drawn a line on greenView:
func getPath() -> UIBezierPath {
let path = UIBezierPath()
path.move(to: CGPoint(x: 0, y: 0))
path.addLine(to: pointDef5)
return path
}
func createLine(on view: UIView) {
let shapeLayer = CAShapeLayer()
view.layer.addSublayer(shapeLayer)
shapeLayer.strokeColor = UIColor.black.cgColor
shapeLayer.lineWidth = 5
shapeLayer.fillColor = nil
shapeLayer.path = getPath().cgPath
}
createLine(on: greenView)
I have removed and added greenView:
greenView.removeFromSuperview()
view.addSubview(greenView)
I see my old line on absurd greenView! How delete my line from my greenView?
greenView + line = forever? I don't know how delete a line