UIButton semanticContentAttribute 属性 在本地化中被强制 RTL
UIButton semanticContentAttribute property is forced RTL in Localization
我正在开发一款支持两种语言(英语和阿拉伯语)的应用程序。我有一个 loginCViewController
,其中我有一个 UIButton and UITextField
。当我切换到 Arabic
时,我的 UIButton semanticContentAttribute
被强制 RightToLeft
,这是我不想要的。
Arabic
English
这是我迄今为止尝试过的方法,但是当切换到阿拉伯语时,我的 UIButton 仍然将它从 RightToLeft 更改为 semanticContentAttribute
。
我希望我的 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)
我正在开发一款支持两种语言(英语和阿拉伯语)的应用程序。我有一个 loginCViewController
,其中我有一个 UIButton and UITextField
。当我切换到 Arabic
时,我的 UIButton semanticContentAttribute
被强制 RightToLeft
,这是我不想要的。
Arabic
English
这是我迄今为止尝试过的方法,但是当切换到阿拉伯语时,我的 UIButton 仍然将它从 RightToLeft 更改为 semanticContentAttribute
。
我希望我的 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)