我正在向屏幕添加一个新图层。所有可见的图层都会根据用户输入移动到随机位置。如何找出子层是否与任何其他层相交/重叠?
// Move position by certain amount
static inline CGPoint CGPointAdd(const CGPoint a, const CGPoint b){
return CGPointMake(a.x + b.x, a.y + b.y);
}
// Add Sublayer
[self.view.layer addSublayer:lineLayer];
// Move all other layers
for(lineLayer in self.view.layer.sublayers){
lineLayer.position = CGPointAdd(lineLayer.position, 50);
}