转载请注明出处:http://www.cnblogs.com/pretty-guy/p/6924882.html
你可以从下载demo
在微博看到几位大牛再说将UIDebuggingInformationOverlay加入豪华午餐,于是乎,自己去看看了介绍。因为博主使用的是Swift语法,而我还没怎么使用Swift(千万别笑我跟不上时代?)。所以,就尝试着用OC的语法来实现了一下,用OC的实现遇到的问题呢就是不知道如何调用通过NSClassFromString生成的Class的类方法,在Google了之后,在找到了答案。下面我就直接贴调用代码咯
- (void)showOverLay{ Class class = NSClassFromString(@"UIDebuggingInformationOverlay"); SEL selector = NSSelectorFromString(@"prepareDebuggingOverlay"); #pragma clang diagnostic push#pragma clang diagnostic ignored "-Warc-performSelector-leaks" [class performSelector:selector]; SEL overlaySelector = NSSelectorFromString(@"overlay"); SEL toggleVisibilitySelector = NSSelectorFromString(@"toggleVisibility"); [[class performSelector:overlaySelector] performSelector:toggleVisibilitySelector];#pragma clang diagnostic pop}
效果图如下: