Create the window for the connecting scene. The touch overlay joins the same scene and follows every resize (rotation, Split View, display changes).
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options: UIScene.ConnectionOptions) {
guard let windowScene = scene as? UIWindowScene else { return }
let window = COSTouchVisualizerWindow(windowScene: windowScene,
morphEnabled: true,
touchVisibility: .remoteAndLocal,
contactConfig: nil,
rippleConfig: nil)
window.rootViewController = RootViewController()
self.window = window
window.makeKeyAndVisible()
}Create the visualizer window with its designated initializer. Passing nil for either configuration uses the default appearance.
import COSTouchVisualizer
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? = COSTouchVisualizerWindow(
frame: UIScreen.main.bounds,
morphEnabled: true,
touchVisibility: .remoteAndLocal,
contactConfig: nil,
rippleConfig: nil
)
}Create the window programmatically in the app delegate, including when the app's view controllers are loaded from a storyboard. The plain init, initWithFrame:, and initWithCoder: initializers are unavailable.
#import <COSTouchVisualizerWindow.h>
- (COSTouchVisualizerWindow *)window {
static COSTouchVisualizerWindow *customWindow = nil;
if (!customWindow) {
customWindow = [[COSTouchVisualizerWindow alloc]
initWithFrame:UIScreen.mainScreen.bounds
morphEnabled:YES
touchVisibility:COSTouchVisualizerWindowTouchVisibilityRemoteAndLocal
contactConfig:nil
rippleConfig:nil];
}
return customWindow;
}Configure the contact and ripple appearance before creating the window:
#import <COSTouchConfig.h>
COSTouchConfig *contactConfig =
[[COSTouchConfig alloc] initWithTouchConfigType:COSTouchConfigTpyeContact];
contactConfig.fillColor = UIColor.yellowColor;
contactConfig.strokeColor = UIColor.purpleColor;
contactConfig.alpha = 0.4;
COSTouchConfig *rippleConfig =
[[COSTouchConfig alloc] initWithTouchConfigType:COSTouchConfigTpyeRipple];
rippleConfig.fillColor = UIColor.yellowColor;
rippleConfig.strokeColor = UIColor.purpleColor;
rippleConfig.alpha = 0.1;
COSTouchVisualizerWindow *window = [[COSTouchVisualizerWindow alloc]
initWithFrame:UIScreen.mainScreen.bounds
morphEnabled:YES
touchVisibility:COSTouchVisualizerWindowTouchVisibilityRemoteAndLocal
contactConfig:contactConfig
rippleConfig:rippleConfig];This project requires iOS 16 or later and ARC.
In Xcode, select File > Add Package Dependencies and enter:
https://github.com/cardinalblue/COSTouchVisualizer.git
Then add COSTouchVisualizer to your app target.
COSTouchVisualizer remains available through CocoaPods. Add the following line to your Podfile:
pod "COSTouchVisualizer"
Add the following line to your Cartfile:
github "cardinalblue/COSTouchVisualizer"
Joe Blau, josephblau@gmail.com
COSTouchVisualizer is available under the MIT license. See the LICENSE file for more info.


