Skip to content

LeoNatan/LNTouchVisualizer

Repository files navigation

LNTouchVisualizer

Touch visualizing framework for iOS.

GitHub release GitHub stars GitHub license PayPal Donation Button

GitHub issues GitHub contributors

Adding to Your Project

Swift Package Manager

Swift Package Manager is the recommended way to integrate LNTouchVisualizer in your project.

LNTouchVisualizer supports SPM versions 5.1.0 and above. To use SPM, you should use Xcode 11 to open your project. Click File -> Swift Packages -> Add Package Dependency, enter https://github.com/LeoNatan/LNTouchVisualizer. Select the version you’d like to use.

You can also manually add the package to your Package.swift file:

.package(url: "https://github.com/LeoNatan/LNTouchVisualizer.git", from: "1.0")

And the dependency in your target:

.target(name: "BestExampleApp", dependencies: ["LNTouchVisualizer"]),

Carthage

Add the following to your Cartfile:

github "LeoNatan/LNTouchVisualizer"

Make sure you follow the Carthage integration instructions here.

Manual

Drag the LNTouchVisualizer.xcodeproj project to your project, and add LNTouchVisualizer.framework to Embedded Binaries in your project target's General tab. Xcode should sort everything else on its own.

CocoaPods

CocoaPods is not supported. There are many reasons for this. Instead of CocoaPods, use Carthage. You can continue using CocoaPods for for your other dependencies and Swift Package Manager for LNTouchVisualizer.

Using the Framework

Swift

While the framework is written in Objective C, it uses modern Objective C syntax, so using the framework in Swift is very easy and intuitive.

Project Integration

Import the module in your project:

import LNTouchVisualizer

Touch Visualization

The easiest way to enable touch visualization for your window scene is to add the following code in your scene delegate:

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
	guard let scene = (scene as? UIWindowScene) else { return }
	scene.touchVisualizerEnabled = true
 
	//This is to configure the system touch visualizer window.
	let rippleConfig = LNTouchConfig.ripple
	rippleConfig.fillColor = .systemRed
	scene.touchVisualizerWindow.touchRippleConfig = rippleConfig
}

This will enable touch visualization for your entire scene by adding a passthrough window for touch visualizations, while allowing you to use your own windows for your app’s UI.

If you’d like to use a touch visualization window on your own, check out the LNTouchVisualizerWindow.h header for more information.

Acknowledgements

Based on COSTouchVisualizer.