swift - UIButton semanticContentAttribute 属性在 Localization 中被强制 RTL
问题描述
我正在开发一个支持两种语言(英语和阿拉伯语)的应用程序。我有一个loginCViewController
,我有一个UIButton and UITextField
。当我切换到 时Arabic
,我UIButton semanticContentAttribute
是被迫的RightToLeft
,这是我不想要的。
Arabic
English
这是我到目前为止所尝试的,但是semanticContentAttribute
当切换到阿拉伯语时,我的 UIButton 仍然从 RightToLeft 更改。
我希望我loginViewController
的两种语言看起来都一样。
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
numberButton.semanticContentAttribute = .forceLeftToRight
}
我什至试过了,viewDidLayoutSubviews()
但结果还是一样。
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
numberButton.semanticContentAttribute = .forceLeftToRight
}
对此的任何帮助将不胜感激。
解决方案
嘿,也许这段代码会对你有所帮助,因为它对我有用。
UIView.appearance().semanticContentAttribute = .forceLeftToRight
let window = self.view.superview
self.view.removeFromSuperview()
window?.addSubview(self.view)
推荐阅读
- javascript - 动态路由 NuxtJS 内的静态页面
- graphql - GraphQL (A = a AND B = b) OR (A = b AND B = a)
- firebase - React Native 如何从其他集合 firestore Flatist 获取数据
- typescript - 我是否需要更新路径才能在 iterm (zsh) 上运行 ts-node?
- c - 使用 gdb 远程调试时找不到当前函数的边界
- c# - Incorrect Data Getting inserted to oda.Fill(dtExcelData) in C# while uploading .csv file for .xls xlsx format the same is working fine
- java - Java Generics - Operator '*' cannot be applied to 'T', 'T'
- php - when i tape bin/console doctrine:database:create i got i error message i have the xampp server
- amazon-web-services - Kuberenetes HPA 展示
- php - 来自 while while 的数字的总和