gpt4 book ai didi

swift - semanticContentAttribute 不再适用于默认的 UITableViewCells

转载 作者:可可西里 更新时间:2023-11-01 01:09:29 25 4
gpt4 key购买 nike

我有一个正在运行的应用程序,我正在尝试添加 RTL 语言支持。

我在我的 AppDelegate 中使用下面的行在启动后执行,特别是在 didFinishLaunchingWithOptions 中。

UIView.appearance().semanticContentAttribute = .forceRightToLeft

它在 iOS 10 上运行完美,但现在在 iOS 11 上,默认的 tableView 单元格的标签仍然对齐 LTR。

current behavior

最佳答案

您还应该将标签的语义内容属性设置为 .forceRightToLeft

程序化

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: <your cell ID>, for: indexPath)
cell.textLabel?.semanticContentAttribute = .forceRightToLeft

return cell
}

在界面生成器中

  1. 选择单元格的文本标签

    text label of cell selected

  2. 从右侧的工具栏中打开属性检查器(左数第四个图标)。

    Attributes inspector selected

  3. View部分,将Semantic选项设置为Force Right-to-Left

    Semantic set to Force Right-to-Left

结果

cell with right-aligned text

关于swift - semanticContentAttribute 不再适用于默认的 UITableViewCells,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48525214/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com