0
有沒有什麼辦法可以檢測到我的應用程序的窗口是否重疊?檢測重疊窗口
有沒有什麼辦法可以檢測到我的應用程序的窗口是否重疊?檢測重疊窗口
使用windows在NSApp表示
//find overlaps
for(NSWindow *w in [NSApp winndows]) {
for(NSWindow *w2 in [NSApp winndows]) {
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....
太好了,謝謝!當一個窗口與另一個窗口相交時,是否還有獲得通知的方法?也許rectDidIntersect或其他東西,所以它不必一直輪詢它? –
好吧,移動或調整大小時會發送通知。你可以註冊這些,然後在通知進入時看看窗口 –
檢查http://stackoverflow.com/questions/11473189/multiple-uiviews-overlapping幫助你。 –