TouchTracker

0.5.1

👆Show a mark at the touched point on the View of SwiftUI and UIKit.
p-x9/TouchTracker

What's New

v0.5.1

2023-10-29T14:52:21Z

What's Changed

Full Changelog: 0.5.0...0.5.1

TouchTracker

Show a mark at the touched point on the View of SwiftUI.

Demo

RPReplay_Final1681306427.MP4

Document

Set the following for a View of SwiftUI.

Text("Hello")
    .touchTrack()

Alternatively, it can also be written as follows

TouchTrackingView {
    Text("Hello")
}

Customize

Text("Hello")
    .touchTrack() // show touch point
    .touchPointRadius(8) // radius of mark on touched point
    .touchPointOffset(x: 0, y: -10) // offset of mark position
    .touchPointColor(.orange) // color of mark on touched point
    .touchPointBorder(true, color: .blue, width: 1) // applying a border to touched points
    .touchPointShadow(true, color: .purple, radius: 3) // shadow on touched points
    .touchPointDisplayMode(.recordingOnly) // display mode of touched points
    .showLocationLabel(true) // show touch coordinate

Example

It is also possible to display images as follow

Text("Hello")
    .touchPointImage(Image(systemName: "swift").resizable())

Example2

UIKit

If you want to adapt it to the entire app created with UIKit, write the following. Use a view named TouchTrackingUIView

import TouchTracker

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    let v = TouchTrackingUIView(isShowLocation: true)

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if let window {
            window.addSubview(v)
            v.translatesAutoresizingMaskIntoConstraints = false

            NSLayoutConstraint.activate([
                v.topAnchor.constraint(equalTo: window.topAnchor),
                v.bottomAnchor.constraint(equalTo: window.bottomAnchor),
                v.leftAnchor.constraint(equalTo: window.leftAnchor),
                v.rightAnchor.constraint(equalTo: window.rightAnchor),
            ])
        }
        return true
    }

Propagate touch events to other windows

The following configuration allows you to share a touch event received in one window with other windows.

v.shouldPropagateEventAcrossWindows = true

In the given configuration, even when windows overlap, typically only one window receives a touch event. Moreover, if a touch event starts in one window, such as Window A, it will only be responsive in Window A, even if it moves to another window, like Window B.

Therefore, the touch event can be shared so that the marker of the tapped point will be displayed in the other window even in such a case.

License

TouchTracker is released under the MIT License. See LICENSE

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Dec 07 2024 12:41:55 GMT-1000 (Hawaii-Aleutian Standard Time)