iOS: Mirror content on screen

Paul Peelen picture Paul Peelen · Dec 20, 2011 · Viewed 11.9k times · Source

I would like to know if it is possible to flip the contents of a UIView within the same device; meaning not to an external monitor but on the device itself.

I have searched a bit on google, but all I can find is to external screens.

Answer

Mats Stijlaart picture Mats Stijlaart · Dec 20, 2011

You can use CGAffineTransformMakeScale with negative values. Like:

CGAffineTransformMakeScale(1.0, -1.0);

This can be applied on the view by:

//Mirror top to bottom
view.transform = CGAffineTransformMakeScale(1.0, -1.0);

or

//Mirror Left to Right
view.transform = CGAffineTransformMakeScale(-1.0, 1.0);