我有一个消息的UIAlertController.我希望警报消息可访问性标签与警报消息字符串不同.
我怎样才能做到这一点?
解决方法
您可以使用子视图数组找到每个UIControl元素.
例如,如果要更改UIAlertController的accessibilityLabel,可以执行以下操作:
let contentTitleForAlert = myAlertController.view.subviews[0].subviews[0].subviews[0].subviews[0].subviews[0].subviews[0] contentTitleForAlert.accessibilityLabel = "¡My text for accessibility label"
使用这种方式,您可以更改UIAlertController中的其他元素.例如:
let contentLabelForAlert = myalertController.view.subviews[0].subviews[0].subviews[0].subviews[0].subviews[0].subviews[1] contentLabelForAlert.accessibilityLabel = "Text for accessibilityLabel for main content in UIAlertController."