简体   繁体   中英

How can I force my app to use the inverse text direction for my Auto Layout constraints?

I've designed my app to use Leading / Trailing constraints.

I do not have localizations for R2L languages but need to show an overlay on windows that might use that direction, and then I need to swap the direction of my controls to match those of the targeted app.

I can figure out which direction the other application uses.

What I can't figure out is an easy way to have my own window use the R2L text direction even though it wants to use L2R direction by default.

I could manually replace all my constraints at runtime, by using Left / Right instead of Leading / Trailing constraints, and then swap them out with the opposite constraints if required. But before I make that effort I like to know if there's an easier way by I can just tell the Auto Layout system to use the opposite direction.

您可以覆盖-userInterfaceLayoutDirectionForSemanticContentAttribute:在Swift中为userInterfaceLayoutDirection(for:) ),以返回所需的视图布局方向。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM