0

I am adding a new layer to the screen. All the layer that are visible are moved to random location based on user input. How to find out if sublayers are intersecting/ overlapping with any other layers?

// 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);
}
Mike D
  • 25
  • 1
  • 4
  • have you tried getting the layers' rects and then calling `CGRectIntersectsRect`? – Louis Tur Jan 02 '15 at 23:12
  • Thanks for feedback. I was working on the code, and the method suggestion does work. Thanks again. And sorry for the late response. – Mike D Feb 04 '15 at 03:13

0 Answers0