Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个应用程序,其中有一个用户可以用手指旋转和平移的矩形。我只是想知道这个旋转视图的框架是什么,这样我就可以知道它是否与另一个矩形相交UIView(不能使用框架属性,因为当 UIView 被转换时它会失效)。实现这一目标的最简单方法是什么?
UIView
每个UIView都有一个frameCGRect 类型的属性。
frame
您可以使用view.frame.
view.frame
应用变换后,您可以使用视图上的 bounds 和 center 属性来获取方向。这可能需要一些计算,但我希望你能轻松完成。
请参阅此问题的答案中的此图像。