updated helper
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
f6287df8f4
commit
90e88f37da
@ -414,7 +414,7 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
||||
/// Used to update any Accessibility properties.
|
||||
open override var accessibilityElements: [Any]? {
|
||||
get {
|
||||
var views = [UIView]()
|
||||
var views = [AnyObject]()
|
||||
|
||||
// grab the available views in order
|
||||
if badgeModel != nil {
|
||||
@ -422,9 +422,9 @@ open class Tilelet: TileContainerBase<Tilelet.Padding> {
|
||||
}
|
||||
|
||||
if titleModel != nil || subTitleModel != nil || eyebrowModel != nil {
|
||||
views.append(titleLockup)
|
||||
let titleLockupViews = gatherAccessibilityElements(from: titleLockup)
|
||||
views.append(contentsOf: titleLockupViews)
|
||||
}
|
||||
|
||||
containerView.setAccessibilityLabel(for: views)
|
||||
|
||||
// get the views to return
|
||||
|
||||
@ -14,14 +14,14 @@ extension UIView {
|
||||
/// - views: Array of Views that you want to join the accessibilityLabel.
|
||||
/// - separator: Separator used between the accessibilityLabel for each UIView.
|
||||
/// - Returns: Joined String.
|
||||
public func combineAccessibilityLabel(for views: [UIView], separator: String = ", ") -> String? {
|
||||
let labels = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0})
|
||||
public func combineAccessibilityLabel(for views: [AnyObject], separator: String = ", ") -> String? {
|
||||
let labels: [String] = views.map({($0.accessibilityLabel?.isEmpty ?? true) ? nil : $0.accessibilityLabel}).compactMap({$0})
|
||||
return labels.joined(separator: separator)
|
||||
}
|
||||
|
||||
/// AccessibilityLabel helper for joining the accessibilityLabel property of all views passed in.
|
||||
/// - Parameter views: Array of Views that you want to join the accessibilityLabel.
|
||||
public func setAccessibilityLabel(for views: [UIView]) {
|
||||
public func setAccessibilityLabel(for views: [AnyObject]) {
|
||||
accessibilityLabel = combineAccessibilityLabel(for: views)
|
||||
}
|
||||
|
||||
@ -50,8 +50,8 @@ extension UIView {
|
||||
return isIntersecting
|
||||
}
|
||||
|
||||
public func gatherAccessibilityElements(from view: UIView) -> [Any] {
|
||||
var elements: [Any] = []
|
||||
public func gatherAccessibilityElements(from view: AnyObject) -> [AnyObject] {
|
||||
var elements: [AnyObject] = []
|
||||
|
||||
for subview in view.subviews {
|
||||
if subview.isAccessibilityElement && subview.isVisibleOnScreen {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user