如果标签上的文本发生更改,是否可以使用 iPhone 上的 VoiceOver 来宣布更新后的文本?
这类似于 ARIA 中的实时区域。
Thanks.
您可以使用 VoiceOver 朗读您喜欢的任何文本:
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, @"Your text");
如果标签应在更新后立即公布其文本,只需扩展UILabel
并覆盖setText
method.
.h 文件:
@interface UIVoicedLabel : UILabel {
}
@end
及其实现:
#import "UIVoicedLabel.h"
@implementation UIVoicedLabel
- (void) setText:(NSString *)text {
// Set the text by calling the base class method.
[super setText:text];
// Announce the new text.
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, text);
}
@end
这对我来说非常有效:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)