UIDebuggingInformationOverlay调试视图

原文链接

方法一 (启动直接显示)

需要写在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

ifdef DEBUG

pragma clang diagnostic push

pragma clang diagnostic ignored "-Warc-performSelector-leaks"

id debugClass = NSClassFromString(@"UIDebuggingInformationOverlay");
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    [debugClass performSelector:NSSelectorFromString(@"prepareDebuggingOverlay")];
});
id debugOverlayInstance = [debugClass performSelector:NSSelectorFromString(@"overlay")];
[debugOverlayInstance performSelector:NSSelectorFromString(@"toggleVisibility")];

pragma clang diagnostic pop

endif

方法二 (双指同时点击状态栏显示)#推荐#

需要写在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

ifdef DEBUG

pragma clang diagnostic push

pragma clang diagnostic ignored "-Warc-performSelector-leaks"

//可视化调试
Class overlay = NSClassFromString(@"UIDebuggingInformationOverlay");
[[overlay class] performSelector:NSSelectorFromString(@"prepareDebuggingOverlay")];

pragma clang diagnostic pop

endif

效果

UIDebuggingInformationOverlay调试视图_第1张图片

你可能感兴趣的:(UIDebuggingInformationOverlay调试视图)