Add accessibility labels to bar button image items.

This commit is contained in:
Maurice Parker
2019-04-27 10:27:36 -05:00
parent 7127f9a911
commit 1730ffb0cc
3 changed files with 84 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
//
// UIBarButtonItem-Extensions.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 4/27/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
public extension UIBarButtonItem {
@IBInspectable var accEnabled: Bool {
get {
return isAccessibilityElement
}
set {
isAccessibilityElement = newValue
}
}
@IBInspectable var accLabelText: String? {
get {
return accessibilityLabel
}
set {
accessibilityLabel = newValue
}
}
var isHidden: Bool {
get {
return tintColor == UIColor.clear
}
set(hide) {
if hide {
isEnabled = false
tintColor = UIColor.clear
} else {
isEnabled = true
tintColor = nil
}
}
}
}