简体   繁体   English

如何获取UIImageView坐标?

[英]how to get UIImageView coordinates?

I have to calculate an angle beetween two UIImageView and i don't find how to get the UIImageViews coordinates(the four corners coordinates). 我必须计算两个UIImageView之间的夹角,但我找不到如何获取UIImageViews坐标(四个角坐标)。 Is there a property for that? 是否有财产?

thanks 谢谢

You should be able to find any angle with trigonometric functions. 您应该能够使用三角函数找到任何角度。

For example, this will find the angle between the centers of two UIImageViews that share a superview: 例如,这将找到共享一个超级视图的两个UIImageViews的中心之间的角度:

angle = tan((imageView1.center.y-imageView2.center.y),
            (imageView1.center.x-imageView2.center.x));

It is important that they are in the same superview, otherwise the coordinates will be different. 它们在同一超级视图中很重要,否则坐标将不同。 To find angles you need to have an understanding of basic trigonometry . 要找到角度,您需要了解基本的三角学

self.frame将为您提供带有视图坐标的CGRect。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM