TouchVisualizer is a lightweight pure Swift implementation for visualising touches on the screen.
To start using TouchVisualizer, write the following line wherever you want to start visualising:
import TouchVisualizer
Then invoke visualisation, by calling:
Visualizer.start()
and stop the presentation like this:
Visualizer.stop()
Get touch locations by this:
Visualizer.getTouches()
import UIKit
import SwiftUI
import TouchVisualizer
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
Visualizer.start()
let contentView = ContentView()
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: contentView)
self.window = window
window.makeKeyAndVisible()
}
}
}
import TouchVisualizer
import SwiftUI
@main
struct Example: App {
init() {
Visualizer.start()
}
var body: some Scene {
WindowGroup {
MainView()
}
}
}
Follow the instructions on developer.apple.com on how to add a Swift Package to your iOS app: Adding Package Dependencies to Your App
- Works with just a single line of code!
- Supports multiple fingers.
- Supports multiple
UIWindow
's. - Displays touch radius (finger size).
- Displays touch duration.
- Customise the finger-points image and colour.
- Supports iPhone and iPad in both portrait and landscape mode.
- iOS 9.0 or later
- Swift 5.0 or later
- Xcode 11 or later
TouchVisualizer also has the ability to customize your touch events. Here is an example of what can be customized:
var config = Configuration()
config.color = UIColor.redColor()
config.image = UIImage(named: "YOUR-IMAGE")
config.showsTimer = true
config.showsTouchRadius = true
config.showsLog = true
Visualizer.start(config)
name | type | description | default |
---|---|---|---|
color | UIColor |
Color of touch point and text. | default color |
image | UIImage |
Touch point image. If rendering mode is set to UIImageRenderingModeAlwaysTemplate , the image is filled with color above. |
circle image |
defaultSize | CGSize |
Default size of touch point. | 60 x 60px |
showsTimer | Bool |
Shows touch duration. | false |
showsTouchRadius | Bool |
Shows touch radius by scaling touch point. It doesn't work on simulator. | false |
showsLog | Bool |
Shows log. | false |
TouchVisualizer is released under the MIT license. Go read the LICENSE file for more information. This fork of TouchVisualizer adds support for Swift 5 and higher as well as support for the Swift Package Manager.