Search code examples
swiftxcodeuikitxcode12

Mirror ImageView for RTL-Language?


How can i mirror a play button image when the language is RTL. I can't find a appropriate option in the Storyboard menu in Xcode 12.


Solution

  • We can use image.imageFlippedForRightToLeftLayoutDirection() method which returns flipped image if current language is RTL(right to left) and then change the imageView's image to it.

    Swift

    playButton.imageView?.image = playButton.imageView?.image?.imageFlippedForRightToLeftLayoutDirection()