From 0460e10b89e26732b961c69fc45b46401afcc7ce Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 20 Jul 2023 12:54:03 -0500 Subject: [PATCH] added edgeInsets Signed-off-by: Matt Bruce --- VDS/Components/Label/Label.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index 7cd75b47..5b0b6ffb 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -33,10 +33,12 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() }} + open var edgeInsets: UIEdgeInsets { textStyle.edgeInsets } + open var textPosition: TextPosition = .left { didSet { setNeedsUpdate() }} open var userInfo = [String: Primitive]() - + override open var text: String? { didSet { attributes = nil @@ -114,6 +116,13 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { shouldUpdateView = true setNeedsUpdate() } + + //-------------------------------------------------- + // MARK: - Overrides + //-------------------------------------------------- + open override func drawText(in rect: CGRect) { + super.drawText(in: rect.inset(by: edgeInsets)) + } //-------------------------------------------------- // MARK: - Overrides @@ -134,7 +143,12 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //set the attributed text attributedText = mutableText + + //get accessibility updateAccessibilityLabel() + + //force a drawText + setNeedsDisplay() } } }