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:

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?

Use right alignment from storyboard as

or from programmatically as

buttonShowOnMap.contentHorizontalAlignment = .left//For left alignment

buttonShowOnMap.contentHorizontalAlignment = .right//For right alignment

No idea why happening but you must subclass UIButton so that you can override alignmentRectInsets.

override func alignmentRectInsets() -> UIEdgeInsets {
    var insets: UIEdgeInsets
    if (Left_Side_Button) {
        insets = UIEdgeInsetsMake(0, 7.0, 0, 0)
    else {
        // Right Button
        insets = UIEdgeInsetsMake(0, 0, 0, 7.0)
    return insets

And achieve it by above code.