有什么方法可以检测我的应用程序中的窗口是否重叠?
使用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....