Change coordinate origin in UIView

后端 未结 2 1712
盖世英雄少女心
盖世英雄少女心 2021-01-21 04:21

Is it possible to change the coordinate system in a UIView so that (0,0) will be the top right hand corner?

相关标签:
2条回答
  • 2021-01-21 05:03

    My answer bars the use of Interface Builder, but I know of no other way.

    After initiating the UIView, perform a CGAffineTransform as such:

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

    Check the documentation for CGAffineTransform. You might also have to translate the view a bit, although I believe it should be good.

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

    Cheers!

    0 讨论(0)
  • 2021-01-21 05:04

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

    should do it for you

    0 讨论(0)
提交回复
热议问题