Abedalkareem / LanguageManager-iOS

A Language manager to handle changing app language without restarting the app. It supports iOS and tvOS.
MIT License
396 stars 67 forks source link

UIBarButtonItem image not rotated. #25

Closed rameezibrahim closed 4 years ago

rameezibrahim commented 5 years ago

I have created the UIBarButtonItem programmatically as follows:

UIBarButtonItem(image: UIImage(named: backButtonIconName), style: .plain, target: self, action: #selector(leftBarButtonAction(_ :)))

How can I rotate the back button for RTL?]

Current screenshot:

Screen Shot 2019-10-01 at 9 52 25 AM
Abedalkareem commented 4 years ago

Hi, What you can do is this:

let backButtonIconName = LanguageManager.shared.isRightToLeft ? "right_arrow" : "left_image"
UIBarButtonItem(image: UIImage(named: backButtonIconName), style: .plain, target: self, action: #selector(leftBarButtonAction(_ :)))

Thank you.