在应用程序上覆盖文本以显示调试信息

Overlay text on the application to show debug information

我基本上是在开发一个 iOS SDK,它将被其他使用 Cocoa pods 的应用程序使用。我的问题是:

是否可行 在主机应用程序的屏幕上覆盖纯文本,向他们显示重要的调试信息(当他们使用该应用程序时)?非常类似于游戏屏幕上的 fps 信息。如果是,建议?

一直在四处寻找,但我能找到的只是关于在相机、地图和视频播放器上叠加的讨论,如下所示:

Is it possible to add a text overlay to videos?

Text overlay not showing in GPUImage iOS

如能提供这方面的指导,我们将不胜感激。

是的,应该是可行的,我会在 window 中添加一个 "debug" 子视图并设置 userInteractionEnabled = NO 这样视图就不会消耗触摸。

像这样的事情应该让你开始:

 #if DEBUG

    UILabel *debugInfo = [[UILabel alloc] init];
    debugInfo.text = @"some debug information here";
    debugInfo.numberOfLines = 0;
    [debugInfo sizeToFit];
    debugInfo.userInteractionEnabled = NO;

    [[[[UIApplication sharedApplication] delegate] window]addSubview:debugInfo];

#endif