Created
October 27, 2015 22:57
-
-
Save futuretap/81d3f46fe05ed68d0c87 to your computer and use it in GitHub Desktop.
Workaround to make UISegmentedControl with images accessible. See http://openradar.appspot.com/radar?id=118413
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UISegmentedControl+Accessibility.m | |
// | |
// Created by Ortwin Gentz on 30.05.14. | |
// Copyright (c) 2014 FutureTap. All rights reserved. | |
// | |
@implementation UISegmentedControl (Accessibility) | |
// Use these convenience setters for easy customization in IB using user defined runtime attributes | |
- (void)setAccessibilityLabel0:(NSString *)accessibilityLabel { | |
[self setAccessibilityLabel:accessibilityLabel forItem:0]; | |
} | |
- (void)setAccessibilityLabel1:(NSString *)accessibilityLabel { | |
[self setAccessibilityLabel:accessibilityLabel forItem:1]; | |
} | |
- (void)setAccessibilityLabel2:(NSString *)accessibilityLabel { | |
[self setAccessibilityLabel:accessibilityLabel forItem:2]; | |
} | |
- (void)setAccessibilityLabel3:(NSString *)accessibilityLabel { | |
[self setAccessibilityLabel:accessibilityLabel forItem:3]; | |
} | |
- (void)setAccessibilityLabel:(NSString *)accessibilityLabel forItem:(NSUInteger)item { | |
if (item >= self.numberOfSegments) { | |
return; | |
} | |
NSUInteger reversedItem = self.numberOfSegments - item - 1; | |
((UIImageView*)self.subviews[reversedItem]).accessibilityLabel = accessibilityLabel; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment