开发者

Change coordinate origin in UIView

Is it possible to change the coordinate system in a UIView s开发者_如何转开发o that (0,0) will be the top right hand corner?


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!


        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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜