Search code examples
iosobjective-cuiviewcgaffinetransform

iOS: Mirror content on screen


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.


Solution

  • 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);