Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #631 from mluu510/read_link_last_option
Browse files Browse the repository at this point in the history
Option to read links last
  • Loading branch information
Jeff Verkoeyen committed Nov 19, 2015
2 parents 84af11d + ea3695a commit 4801e90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/attributedlabel/src/NIAttributedLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ extern NSString* const NIAttributedLabelLinkAttributeName; // Value is an NSText

@property (nonatomic, copy) NSString* tailTruncationString;

@property (nonatomic) BOOL shouldSortLinksLast; // Sort the links in the text as the last elements in accessible elements. Default: NO

- (void)setFont:(UIFont *)font range:(NSRange)range;
- (void)setStrokeColor:(UIColor *)color range:(NSRange)range;
- (void)setStrokeWidth:(CGFloat)width range:(NSRange)range;
Expand Down
8 changes: 5 additions & 3 deletions src/attributedlabel/src/NIAttributedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -1480,16 +1480,18 @@ - (NSArray *)accessibleElements {
}
}

// Add this label's text as the "bottom-most" accessibility element, i.e. the last element in the
// array. This gives link priorities.
NIViewAccessibilityElement* element = [[NIViewAccessibilityElement alloc] initWithAccessibilityContainer:self frameInContainer:self.bounds];
element.accessibilityLabel = self.attributedText.string;
// Set the frame to fallback on if |element|'s accessibility container is changed externally.
CGRect boundsInWindowCoordinates = [self convertRect:self.bounds toView:nil];
CGRect boundsInScreenCoordinates = [self.window convertRect:boundsInWindowCoordinates toWindow:nil];
element.accessibilityFrame = boundsInScreenCoordinates;
element.accessibilityTraits = UIAccessibilityTraitNone;
[accessibleElements addObject:element];
if (_shouldSortLinksLast) {
[accessibleElements insertObject:element atIndex:0];
} else {
[accessibleElements addObject:element];
}

_accessibleElements = [accessibleElements copy];
return _accessibleElements;
Expand Down

0 comments on commit 4801e90

Please sign in to comment.