0

Is there any way I can detect if windows from my application are overlapping ?

4

1 回答 1

2

在 NSApp 中使用窗口

//find overlaps
for (NSWindow *w in [NSApp windows]) {
   for (NSWindow *w2 in [NSApp windows]) {
      if (CGRectIntersectsRect(w.frame, w2.frame) || CGRectIntersectsRect(w2.frame, w.frame)) {
          // add the pairs w & w2 up in a NSDictionary with w as key and an array of w2s it intersects 
          // ....
      }
   }
}

//handle all the queued overlaps....
于 2012-11-11T20:27:09.323 回答