diff --git a/AsyncDisplayKit/ASButtonNode.mm b/AsyncDisplayKit/ASButtonNode.mm index c021c35729..2990fe2e87 100644 --- a/AsyncDisplayKit/ASButtonNode.mm +++ b/AsyncDisplayKit/ASButtonNode.mm @@ -60,6 +60,7 @@ _contentHorizontalAlignment = ASAlignmentMiddle; _contentVerticalAlignment = ASAlignmentCenter; _contentEdgeInsets = UIEdgeInsetsZero; + self.accessibilityTraits = UIAccessibilityTraitButton; } return self; } @@ -102,6 +103,11 @@ - (void)setEnabled:(BOOL)enabled { [super setEnabled:enabled]; + if (enabled) { + self.accessibilityTraits = UIAccessibilityTraitButton; + } else { + self.accessibilityTraits = UIAccessibilityTraitButton | UIAccessibilityTraitNotEnabled; + } [self updateButtonContent]; } @@ -135,7 +141,7 @@ - (void)updateImage { ASDN::MutexLocker l(_propertyLock); - + UIImage *newImage; if (self.enabled == NO && _disabledImage) { newImage = _disabledImage; @@ -170,9 +176,10 @@ } else { newTitle = _normalAttributedTitle; } - + if ((_titleNode != nil || newTitle.length > 0) && newTitle != self.titleNode.attributedString) { _titleNode.attributedString = newTitle; + self.accessibilityLabel = _titleNode.accessibilityLabel; [self setNeedsLayout]; } } @@ -331,6 +338,7 @@ default: break; } + [self updateTitle]; } diff --git a/AsyncDisplayKit/ASControlNode.mm b/AsyncDisplayKit/ASControlNode.mm index 54ac169f0d..41b41b091d 100644 --- a/AsyncDisplayKit/ASControlNode.mm +++ b/AsyncDisplayKit/ASControlNode.mm @@ -77,6 +77,7 @@ static BOOL _enableHitTestDebug = NO; } #pragma mark - Lifecycle + - (id)init { if (!(self = [super init])) @@ -89,6 +90,13 @@ static BOOL _enableHitTestDebug = NO; return self; } +- (void)setUserInteractionEnabled:(BOOL)userInteractionEnabled +{ + [super setUserInteractionEnabled:userInteractionEnabled]; + self.isAccessibilityElement = userInteractionEnabled; +} + + #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wobjc-missing-super-calls"