TouchInspector - 一个嵌入式软件包,可帮助您在 iOS 和 iPadOS 上可视化和调试触摸
触摸检查器
TouchInspector 是一个轻量级软件包,可帮助您在 iOS 和 iPadOS 上可视化和调试触摸。
从设备或模拟器录制和共享演示时,显示触摸非常有用。
TouchInspector 还可以选择显示命中测试信息(即触摸正在点击的视图)。在尝试识别某些视图的类型或调试触摸的实际去向时,这非常有用。
安装
将 TouchInspector 添加到 app 文件,或在 Xcode 中选择:Package.swift
File -> Add Packages
.package(url: "https://github.com/jtrivedi/TouchInspector", from: "0.1.0"))
用法
您需要将应用程序/场景的类型更改为 ,您可以在开发时有条件地执行此操作:window
TouchInspectorWindow
import TouchInspector
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else {
return
}
#if DEBUG
window = TouchInspectorWindow(windowScene: windowScene)
#else
window = UIWindow(windowScene: windowScene)
#endif
window?.rootViewController = ViewController()
window?.makeKeyAndVisible()
}
Touch and hit-testing visualization is enabled by default when creating a . You can change that with the following properties:TouchInspectorWindow
// Show the touch indicator, but not the hit-testing overlay.
window.showTouches = true
window.showHitTesting = false