Iulian Onofrei
Iulian Onofrei

Reputation: 9720

Stop UIImage flip for right to left languages

I added an Image Set to the Asset Catalog and set its Direction to Left to Right, Mirrors. I then added an UIImageView in my view controller and if the device's language is set to a right to left language, the image shows up flipped.

I would like for it not to flip in this case, as I'm manually managing the mother language inside the app. I tried setting the UIImageView's Semantic to Force Left-to-Right to no avail.

Upvotes: 0

Views: 1946

Answers (1)

André Slotta
André Slotta

Reputation: 14030

For me the following works:

Set the image set's direction to Left to Right, Mirrors.

image set

Force a specific direction for the UIImageView:

Objective-C

- (void)setImageView:(UIImageView *)imageView {
    _imageView = imageView;
    _imageView.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
}

Swift

@IBOutlet weak var imageView: UIImageView! {
    didSet {
        imageView.semanticContentAttribute = .forceRightToLeft
    }
}

Now the image gets mirrored in an LTR environment as well as an RTL environment. If I set it to .forceLeftToRight instead the image does not get mirrored on any environment.

Upvotes: 3

Related Questions