https://github.com/LukasCZ/GSTouchesShowingWindow-Swift
Surface all touches in your iOS app when creating videos!
https://github.com/LukasCZ/GSTouchesShowingWindow-Swift
apppreview uiwindow video
Last synced: 6 months ago
JSON representation
Surface all touches in your iOS app when creating videos!
- Host: GitHub
- URL: https://github.com/LukasCZ/GSTouchesShowingWindow-Swift
- Owner: LukasCZ
- License: mit
- Created: 2017-08-25T10:48:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-07T22:12:06.000Z (over 4 years ago)
- Last Synced: 2024-11-10T18:53:16.376Z (7 months ago)
- Topics: apppreview, uiwindow, video
- Language: Swift
- Size: 3.11 MB
- Stars: 379
- Watchers: 11
- Forks: 20
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# GSTouchesShowingWindow-Swift
A simple tool that automatically **shows all touches** inside your app as they are happening, using a circular image indicator. It's useful for creating **App Previews** for the App Store or any kind of **app videos** where you need to demonstrate some rich user interaction that would be hard to showcase otherwise.
(Looking for Objective-C version? It's [here](https://github.com/LukasCZ/GSTouchesShowingWindow).)
## Example
Short interaction in [Timelines](https://timelinesapp.io), my app for tracking time.
## Installation
GSTouchesShowingWindow is available through [CocoaPods](http://cocoapods.org). To install it, simply add the following line to your Podfile:
```ruby
pod 'GSTouchesShowingWindow-Swift'
```Alternatively, you can just drag `GSTouchesShowingWindow-Swift/Classes` and `GSTouchesShowingWindow-Swift/Assets.xcassets` into your project.
## How to set it up
In your `AppDelegate.swift`, replace `var window: UIWindow?` with the following code:
```Swift
var customWindow: GSTouchesShowingWindow?
var window: UIWindow? {
get {
customWindow = customWindow ?? GSTouchesShowingWindow(frame: UIScreen.main.bounds)
return customWindow
}
set { }
}
```If you're using the CocoaPods integration, you also need to add the following import at the top of the file:
```Swift
import GSTouchesShowingWindow_Swift
```And that's it!
### App Extensions
If you are using App Extensions (such as Today extension or Keyboard extension), you can also show touches in them.
First, you need to integrate GSTouchesShowingWindow-Swift in your App Extension target. If you're using CocoaPods, you need to add the pod like this:```ruby
target 'Today Extension' do
use_frameworks!
pod 'GSTouchesShowingWindow-Swift'
end
```If you're not using CocoaPods, you need to either drag the `GSTouchesShowingWindow-Swift/Classes` into your extension's target, or you can set their **Target Membership** to include the extension as well:

Then, in your `KeyboardViewController.m` or `TodayViewController.m`, add the following line near the end of `-viewDidLoad:` method:
```Swift
self.view.addGestureRecognizer(GSTouchesShowingGestureRecognizer())
```Same as with main app target: if you're using the CocoaPods integration, you also need to import the module using:
```Swift
import GSTouchesShowingWindow_Swift
```Note: In Today extensions (Widgets), the touch will disappear shortly after you start dragging (both horizontally and vertically). That's to be expected because system takes over control of the gesture.
## How it actually works
Inside the UIWindow subclass, I am overriding the `-sendEvent` method, processing all the events and directing them to a controller object that takes care of adding/moving/removing imageViews based on those events' touches. And then I call `[super sendEvent];` so that the touches are forwarded to the app itself. Refer to [Understanding Responders and the Responder Chain](https://developer.apple.com/library/content/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/HandlngEventsUsingtheResponderChain.html) to learn more. For extensions, a `UIGestureRecognizer` subclass is used because it's not possible to override window.
If you have any questions, you're welcome to get in touch with me on Twitter [@luksape](http://twitter.com/luksape). And if you use this when creating your app video, I'd love to hear from you!