Beginning stages of accessibility.
This commit is contained in:
parent
c06a15c91b
commit
f67392eb69
@ -14,7 +14,7 @@ public typealias ActionBlock = () -> Void
|
|||||||
|
|
||||||
@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol {
|
@objcMembers open class Label: UILabel, MVMCoreViewProtocol, MVMCoreUIMoleculeViewProtocol, MVMCoreUIViewConstrainingProtocol, MFButtonProtocol {
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - General Properties
|
// MARK: - Properties
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
public var makeWholeViewClickable = false
|
public var makeWholeViewClickable = false
|
||||||
@ -63,6 +63,7 @@ public typealias ActionBlock = () -> Void
|
|||||||
numberOfLines = 0
|
numberOfLines = 0
|
||||||
lineBreakMode = .byWordWrapping
|
lineBreakMode = .byWordWrapping
|
||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
isAccessibilityElement = false
|
||||||
|
|
||||||
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(textLinkTapped(_:)))
|
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(textLinkTapped(_:)))
|
||||||
tapGesture.numberOfTapsRequired = 1
|
tapGesture.numberOfTapsRequired = 1
|
||||||
@ -152,7 +153,7 @@ public typealias ActionBlock = () -> Void
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
// MARK: - Functions
|
// MARK: - Style
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
@objc public static func setLabel(_ label: UILabel?, withHTML html: String?) {
|
@objc public static func setLabel(_ label: UILabel?, withHTML html: String?) {
|
||||||
@ -272,12 +273,6 @@ public typealias ActionBlock = () -> Void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
|
||||||
// MARK: - Methods
|
|
||||||
//------------------------------------------------------
|
|
||||||
|
|
||||||
@objc public func styleH1(_ scale: Bool) {
|
@objc public func styleH1(_ scale: Bool) {
|
||||||
MFStyler.styleLabelH1(self, genericScaling: false)
|
MFStyler.styleLabelH1(self, genericScaling: false)
|
||||||
setScale(scale)
|
setScale(scale)
|
||||||
@ -567,3 +562,49 @@ extension UITapGestureRecognizer {
|
|||||||
return NSLocationInRange(indexOfGlyph, targetRange)
|
return NSLocationInRange(indexOfGlyph, targetRange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Accessibility
|
||||||
|
extension Label {
|
||||||
|
|
||||||
|
override open func accessibilityActivate() -> Bool {
|
||||||
|
let point = accessibilityActivationPoint
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func accessibilityElementDidBecomeFocused() {
|
||||||
|
<#code#>
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func accessibilityElementCount() -> Int {
|
||||||
|
return accessibleClauses.count
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func accessibilityElement(at index: Int) -> Any? {
|
||||||
|
return accessibleClauses[index]
|
||||||
|
}
|
||||||
|
|
||||||
|
open override func index(ofAccessibilityElement element: Any) -> Int {
|
||||||
|
return accessibleClauses.firstIndex(of: element as! UIAccessibilityElement)!
|
||||||
|
}
|
||||||
|
|
||||||
|
var accessibleClauses: [UIAccessibilityElement] {
|
||||||
|
|
||||||
|
var elements = [UIAccessibilityElement]()
|
||||||
|
|
||||||
|
for clause in clauses {
|
||||||
|
|
||||||
|
let element = UIAccessibilityElement(accessibilityContainer: self)
|
||||||
|
let rect = CGRect(x: 10, y: 10, width: 100, height: 30)
|
||||||
|
element.accessibilityFrame = rect
|
||||||
|
// element.accessibilityFrame = convert(conceptualSize(range: clause.range)!, to: nil)
|
||||||
|
element.accessibilityFrameInContainerSpace = rect
|
||||||
|
element.accessibilityLabel = "Testing"
|
||||||
|
element.accessibilityTraits = .button
|
||||||
|
element.isAccessibilityElement = true
|
||||||
|
elements.append(element)
|
||||||
|
}
|
||||||
|
accessibilityElements = elements
|
||||||
|
return elements
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user