【问题标题】:Segmented Control: Accessibility Long Press Font Color Issue分段控制:可访问性长按字体颜色问题
【发布时间】:2020-12-05 03:48:18
【问题描述】:

我一直在开发一个 iOS 项目,该项目需要各种场景的可访问性,我遇到了以下问题。

当我们长按可访问性字体大小时,设置选定段的文本颜色会导致问题。由于文本在常规 UI 中为白色,背景为深蓝色,因此当我们长按弹出菜单(无障碍大小的默认 iOS 选项)时,它会保留字体颜色,但会删除背景颜色。

我似乎无法找到一种方法来访问此弹出菜单的字体颜色或背景颜色,以无障碍文本大小显示。

我搜索了其他问题,很难找到有关iOS此功能的信息。

我正在像这样设置我的字体颜色:

let titleTextAttributes: [NSAttributedString.Key : AnyObject] = [NSAttributedString.Key.foregroundColor: UIColor(named:"textWhite")!, NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 24)]

segCont.setTitleTextAttributes(titleTextAttributes, for: .selected)

我知道问题在于 NSAttributedString.Key.foregroundColor 属性,就好像我将它从白色更改为深色文本颜色一样,它看起来很好。

为了清楚起见,我已包含问题的图片。 任何人都可以提供的任何帮助或澄清将不胜感激。

Segmented Control Accessibility Long press

【问题讨论】:

    标签: swift xcode accessibility uisegmentedcontrol ios14


    【解决方案1】:

    解决方案最终是属性字符串中的一个额外属性 backgroundColor。 它仍然不完美,但清晰易读且明显更好。

    ''' 让 titleTextAttributes: [NSAttributedString.Key : AnyObject] = [NSAttributedString.Key.foregroundColor: Theme.segContSelectedText!, NSAttributedString.Key.font: Theme.segContSelectedFont, NSAttributedString.Key.backgroundColor: Theme.segContSelectedTint!]

    segCont.setTitleTextAttributes(titleTextAttributes, for: .selected) '''

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-03
      • 1970-01-01
      • 2011-08-18
      • 2014-02-19
      • 2020-06-28
      • 1970-01-01
      • 2021-08-10
      • 1970-01-01
      相关资源
      最近更新 更多