更改UIView中的坐标原点 [英] Change coordinate origin in UIView

查看:106
本文介绍了更改UIView中的坐标原点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以更改UIView中的坐标系,以便(0,0)将位于右上角?

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

推荐答案

在启动UIView之后,执行CGAffineTransform,如下所示:

After initiating the UIView, perform a CGAffineTransform as such:

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

检查CGAffineTransform的文档。你可能还需要翻译视图一点,虽然我相信它应该是好的。

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

上面的-1翻转x坐标系。每当您以编程方式提交新视图时,都会按照您的希望工作。

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

干杯!

这篇关于更改UIView中的坐标原点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆