Search code examples
iosswift3uibuttonxcode8

UIButton title alignment not changing to right direction in RTL


I am having an application in both LTR and RTL languages. Everything is fine but the UIButton title alignment is not changing to right though the UIButton flips itself. Here is the screenshot: UIButton in RTL

Alignment Given

Constraints given for default language english:

Constraints given for default language english:

What is the issue and why it happens? Do we need to set the title programatically aligned to right?


Solution

  • Use right alignment from storyboard as

    enter image description here

    or from programmatically as

    buttonShowOnMap.contentHorizontalAlignment = .left//For left alignment
    
    buttonShowOnMap.contentHorizontalAlignment = .right//For right alignment