目录
目录README.md

TouchTracker

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

Demo

https://user-images.githubusercontent.com/50244599/231504004-e1a1e815-3156-4f03-ba52-316afa061781.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
    .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
    }
关于
90.0 KB
邀请码