right to left trait collection not respected by UIKit controls.

Originator:crayment16
Number:rdar://49643040 Date Originated:April 5 2019
Status: Resolved:
Product:iOS + SDK Product Version:iOS 12.1 (16B91)
Classification:UI/Usability Reproducible:Always
 
Summary:

UIKit gives us UITraitCollection which is great. It lets us control the context our views render in. Unfortunately when using UITraitCollection(layoutDirection: .rightToLeft) the built in UIKit controls do not behave as you would expect. This inhibits our ability to test for these conditions.

Please see this gist: https://gist.github.com/crayment/8d9e9b97796b42e98d1d0a9ac5622bc8

And some more discussion around it in the context of snapshot testing here: https://github.com/pointfreeco/swift-snapshot-testing/issues/168

Steps to Reproduce:
- Create a UIViewController
- Call setOverrideTraitCollection with UITraitCollection(layoutDirection: .rightToLeft)
- Add UIButtons, UILabels, UITextFields, UISwitches, etc to the view of the UIVIewController


Expected Results:
- UILabel's to wrap on the right
- UITextFields placeholders to be right aligned
- UISwitch to be ON when on the left
- etc.

Actual Results:
- Everything appears in left to right mode. Although UISwitch does seem to correct itself when interacted with.

Version/Build:
iOS 12.1 (16B91)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!