UINavigationItem -title是否提供辅助功能?

时间:2011-01-02 03:11:28

标签: iphone objective-c cocoa cocoa-touch accessibility

我正在尝试为VoiceOver用户提供略有不同版本的UINavigationItem个标题。由于文本到语音引擎会破坏缩写,显示的标题对于视障人士来说并不适用。

有没有办法以accessibilityLabel的形式添加对这些标题的可访问性提示?

1 个答案:

答案 0 :(得分:2)

好吧,似乎将accessibilityLabel添加到UINavigationItem的唯一方法是创建一个自定义UILabel,如下所示:

- (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];
}