Search code examples
swiftautolayoutuitextfieldios9placeholder

Weird UITextField Placeholder Behaviour On RTL iOS9


On creating the UITextField from a xib and calling the resignFirstResponder() method on RTL keyboard language the UITextField placeholder align is right.

On creating the textField programmatically and calling the resignFirstResponder() method on RTL keyboard language the UITextField placeholder align is left.

let txtField = UITextField(frame: CGRectMake(0, 0, 200, 50))

I want to use the UITextField from the xib file and not programmatically.

Note: clearing all the constraints doesn’t help. The problem is only in iOS 9

I don’t know why on creating the UITextField from the xib file the placeholder behave differently,

Please help.


Solution

  • Check the value of semanticContentAttribute (a property of UIView) that let you determine the direction of the layout LTR/RTL.

    It was introduced on iOS 9 as part of an improved system support for RTL and it might be the cause for the difference you see between iOS 8 and 9.