为什么设置图层边界矩形的anchorPoint表现得如此奇怪? [英] Why does setting the anchorPoint of the layer's bounds rectangle behave so strange?

查看:58
本文介绍了为什么设置图层边界矩形的anchorPoint表现得如此奇怪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试设置anchorPoint属性,以便通过定义良好的轴旋转视图。
但是:

I try to set the anchorPoint property, in order to rotate a view by a well defined axis. But:

myView.layer.anchorPoint = CGPointMake(myView.layer.anchorPoint.x - 1.0, myView.layer.anchorPoint.y);

Wenn我将其移动-1.0,它不仅会向左移动1个单位。相反,我的整个视图向右移动。

Wenn I shift it by -1.0, it will not just move 1 unit to left. Instead, my whole view moves by the width of the view to right.

那是什么坐标系?好像倒了。但是,单位也与例如myView.frame.size.width的单位不匹配?

What kind of coordinate system is that? It seems inverted. But also the units don't match with those of for example myView.frame.size.width ?

推荐答案

anchorPoint是标准化的在图层中的位置。也就是说,(0.0,0.0)是图层的左上角(在iPhone的翻转的UIView图层坐标系中),而(1.0,1.0)是图层的右下角。 (0.5,0.5)是图层的中间。这些位置与大小无关,因此也只是相对位置。

anchorPoint is a normalized position within your layer. That is, (0.0, 0.0) is the upper-left corner of your layer (in the iPhone's flipped UIView layer coordinate system) and (1.0, 1.0) is the lower-right corner. (0.5, 0.5) is the middle of your layer. These positions are size-independent, and thus merely relative locations.

这使得可以围绕该anchorPoint进行缩放,如果anchorPoint是绝对坐标,这将造成混淆

This makes it possible to scale about that anchorPoint, which would be confusing to do if anchorPoint was an absolute coordinate.

这篇关于为什么设置图层边界矩形的anchorPoint表现得如此奇怪?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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