我有一个支持不同语言的iOS应用程序,它使用LTR Storyboard和RTL Storyboard,并从Plists中读取.当我在带有英文iOS版本的设备上运行应用程序时,在语言之间切换时,一切看起来都很完美.但是当我将iPhone OS语言改为RTL语言时.用户界面搞砸了.
特别是当我启用本地化以更改主屏幕上的应用程序名称时,会发生这种情况.
知道为什么会这样吗?
例如,整个菜单搞砸了,它应该在左侧,而它应该在右侧,菜单项图标必须在左侧,标签在右侧.
最佳答案 这是因为您使用前导和尾随约束.
在LTR环境中,领导意味着在RTL环境中,领先意味着正确.
这是Apple帮助我们轻松处理RTL / LTR的方式:[在您的情况下,不是那么多……
要禁用此行为,请更改视图的语义属性.
Semantic Content
If you lay out your views using leading and trailing constraints, the
views automatically flip positions when switching between
left-to-right languages (like English) and right-to-left languages
(like Arabic). However, some interface elements should not change
their position based on the reading direction. For example, buttons
that are based on physical directions (up, down, left, and right)
should always stay in the same relative orientation.The view’s semanticContentAttribute property determines whether the
view’s content should flip when switching between left-to-right and
right-to-left languages.In interface builder, set the Semantic option in the Attribute
inspector. If the value is Unspecified, the view’s content flips with
the reading direction. If it is set to Spatial, Playback, or Force
Left-to-Right, the content is always laid out with the leading edges
to the left and trailing edges to the right. Force Right-to-Left
always lays out the content with the leading edges to the right and
the trailing edges to the left.