Does UINavigationItem -title provide accessibility features?
I am trying to provide VoiceOver users with slightly different versions of my UINavigationItem
titles. The displayed titles don't quite work for the visual impaired due to abbreviations that get mangled by the text to speech engine.
Is there any way to add开发者_JAVA技巧 accessibility hinting to these titles in form of a accessibilityLabel
?
Well, it appears the only way to add an accessibilityLabel
to a UINavigationItem
is by creating a custom UILabel
like so:
- (void)viewDidLoad
{
[super viewDidLoad];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 120, 44)];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:20];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor darkGrayColor];
label.shadowOffset = CGSizeMake(0, -1);
label.text = @"Human readable string incl. abbreviations";
label.accessibilityLabel = @"VoiceOver friendly text";
[self.navigationItem setTitleView:label];
[label sizeToFit];
[label release];
}
精彩评论