add accessibility and constants

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-05-25 10:25:44 -05:00
parent a872cf801c
commit 9c0e0cf0e8

View File

@ -43,7 +43,7 @@ extension Tabs {
open var selected: Bool = false { didSet { setNeedsUpdate() } }
///The text label of the tab.
open var text: String? { didSet { setNeedsUpdate() } }
open var text: String = "Tab" { didSet { setNeedsUpdate() } }
///Minimum width for the tab
open var minWidth: CGFloat = 44.0 { didSet { setNeedsUpdate() } }
@ -87,6 +87,8 @@ extension Tabs {
super.setup()
addSubview(label)
backgroundColor = .clear
accessibilityTraits = .button
label.backgroundColor = .clear
label.translatesAutoresizingMaskIntoConstraints = false
@ -104,8 +106,7 @@ extension Tabs {
let layoutGuide = UILayoutGuide()
addLayoutGuide(layoutGuide)
labelWidthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: 44.0)
labelWidthConstraint = layoutGuide.widthAnchor.constraint(greaterThanOrEqualToConstant: minWidth)
labelWidthConstraint?.isActive = true
//activate the constraints
@ -131,7 +132,7 @@ extension Tabs {
if let width, orientation == .vertical {
labelWidthConstraint = label.widthAnchor.constraint(equalToConstant: width)
} else {
labelWidthConstraint = label.widthAnchor.constraint(greaterThanOrEqualToConstant: 44.0)
labelWidthConstraint = label.widthAnchor.constraint(greaterThanOrEqualToConstant: minWidth)
}
labelWidthConstraint?.isActive = true