1,UIWindow *window = [UIApplication sharedApplication].keyWindow; // 獲得根窗口
2.
- (UIView *)rootView {
UIView *rootView = self;
while (rootView.superview) {
if ([rootView.superview isKindOfClass:[UIWindow class]]) {
break;
}
rootView = rootView.superview;
}
return rootView;
}