检查ViewController上是否存在重叠对象

3

如何以编程方式检查我的UIViewController上的2个对象是否重叠?我正在使用此方法随机移动UIView上的对象。

CGFloat x = (CGFloat) (arc4random() % (int) self.container.bounds.size.width);
CGFloat y = (CGFloat) (arc4random() % (int) self.container.bounds.size.height);

CGPoint squarePostion = CGPointMake(x, y);
_button.center = squarePostion;

我有三个物体,我正在使用以下代码片段移动它们。有时它们会重叠在一起,这是一个问题。我是否可以在将它们可见之前检查这些对象是否重叠?
谢谢大家!


请查看http://stackoverflow.com/questions/23247919/check-if-cgrect-is-contained-within-another-transformed-rect - svrushal
1个回答

4

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接