fixed issue with line.

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-09-15 14:57:17 -05:00
parent 8603cd7cb1
commit 55f922e5a1

View File

@ -41,6 +41,12 @@ open class Line: View {
case horizontal, vertical
}
//--------------------------------------------------
// MARK: - Configuration
//--------------------------------------------------
/// Width of the line.
public let lineWidth: CGFloat = 1.0
//--------------------------------------------------
// MARK: - Public Properties
//--------------------------------------------------
@ -83,9 +89,7 @@ open class Line: View {
open override func updateView() {
super.updateView()
backgroundColor = lineViewColorConfiguration.getColor(self)
invalidateIntrinsicContentSize()
setNeedsDisplay()
}
/// Resets to default settings.
@ -94,4 +98,22 @@ open class Line: View {
style = .primary
orientation = .horizontal
}
open override func draw(_ rect: CGRect) {
guard let context = UIGraphicsGetCurrentContext() else { return }
context.setStrokeColor(lineViewColorConfiguration.getColor(self).cgColor)
context.setLineWidth(lineWidth)
if orientation == .horizontal {
context.move(to: CGPoint(x: 0, y: rect.height / 2))
context.addLine(to: CGPoint(x: rect.width, y: rect.height / 2))
} else {
context.move(to: CGPoint(x: rect.width / 2, y: 0))
context.addLine(to: CGPoint(x: rect.width / 2, y: rect.height))
}
context.strokePath()
}
}