From bbdf496cda5bd10fe2d02ef996059acd8c908d8d Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Thu, 15 Jun 2023 18:50:30 -0500 Subject: [PATCH] added edgeInset Signed-off-by: Matt Bruce --- VDS/Components/Label/Label.swift | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index c88ab853..c460530b 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -39,6 +39,14 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open var userInfo = [String: Primitive]() + open var edgeInset: UIEdgeInsets = .zero { + didSet { + setNeedsUpdate() + + } + + } + override open var text: String? { didSet { attributes = nil @@ -192,7 +200,16 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { attributedString.addAttribute( .paragraphStyle, value: paragraph, range: entireRange) } } - + + open override func drawText(in rect: CGRect) { + super.drawText(in: rect.inset(by: edgeInset)) + } + + open override var intrinsicContentSize: CGSize { + let size = super.intrinsicContentSize + return CGSize(width: size.width + edgeInset.left + edgeInset.right, height: size.height + edgeInset.top + edgeInset.bottom) + } + //-------------------------------------------------- // MARK: - Actionable //--------------------------------------------------