Changing coordinates in a UIView

Is it possible to change the coordinate system in a UIView so that (0,0) is the upper right corner?

+3
source share
2 answers

My answer uses Interface Builder, but I don’t know another way.

After starting UIView, execute CGAffineTransform as such:

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

Check the documentation for CGAffineTransform. You may also have to translate the presentation a bit, although I think it should be fine.

"-1" inverts the x coordinate system there. Whenever you introduce a new view programmatically, it will work as you hope.

Hooray!

+3
source


        self.view.transform = CGAffineTransformMakeRotation(90.0*0.0174532925);
        self.view.bounds = CGRectMake(0.0f, 0.0f, 480.0f, 320.0f);

gotta do it for you

+1
source

Source: https://habr.com/ru/post/1744956/


All Articles