Search code examples
ipaduiviewcgaffinetransform

Mirroring UIViews


I am working on an application that supports multiple languages. In order to support languages that start from right to left, I am transforming the view so that views on the right side get shifted to left side as shown in the images below:

View Before Transforming

enter image description here

I am using the following code to transform the view

 self.view.transform = CGAffineTransformMakeScale(-1, 1);

What I now want to do is transform the views in its new position in the left to remove the mirrored text. For example, I want to flip the "FLIP LABEL" about its center so that the text is displayed properly. How do I do this?


Solution

  • You could try running the same transform again on the individual subviews - for example:

    for (UIView *view in self.view.subviews) {
        view.transform = CGAffineTransformMakeScale(-1, 1);
    }
    

    (Or maybe it would be CGAffineTransformMakeScale(1, 1)? I'm not totally sure.)