有什么方法可以检测应用程序中的窗口是否重叠?

最佳答案

使用NSApp中的Windows

//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....

关于objective-c - 检测重叠窗口,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13334941/

10-10 15:24