如果有人能告诉我如何能够发现我的某个子视图与任何内容重叠(我的意思是某些警报或类似内容),我将不胜感激。
答案 0 :(得分:2)
您可以在运行应用时在xcode中查看自己。请按照以下步骤操作。
答案 1 :(得分:1)
使用以下代码..
TableRows
此处- (void)checkAnyViewOverlappingViewFrame:(UIView*)view topLevelView:(UIView *)toplevelview viewToSearch:(UIView*)viewtosearch {
// Get the subviews of the view
NSArray *subviews = [viewtosearch subviews];
// Return if there are no subviews
if ([subviews count] == 0) return; // COUNT CHECK LINE
for (UIView *subview in subviews) {
CGRect frameRelativeToParent = [subview convertRect:subview.bounds
toView:toplevelview];
if (CGRectIntersectsRect(view.frame, frameRelativeToParent) && view.layer.zPosition < subview.layer.zPosition) {
NSLog(@"Overlapping view: %@", subview);
}
[self checkAnyViewOverlappingViewFrame:view topLevelView:toplevelview viewToSearch:subview];
}
}
是您需要检查的子视图。在view
传递toplevelview
所有视图的父视图。在self.view
传递viewtosearch