Use to intercept when a user takes a screenshot and allow user to perform an action
- Download
ScreenshotDetectionView.swift
and drag into project. - Initialize
ScreenshotDetectionView()
and add as a subview to a ViewController. - When a screenshot is taken, the method passed in as a selector in the ViewController class will be called. This can be set to repeat with the repeat: field in the initializer of
ScreenshotDetectionView()
Initialize view and add as a subview
//place in view controller
let detectView = ScreenshotDetectionView(parent: self, title: "title", message: "this is a message", selector: Selector("screenshotHandler"), repeats: true)
view.addSubview(detectView)
Create a method to handle response to "ok" of alert view
func screenshotHandler() {
//gets called after user presses ok on alert
//perform some function here
}
Build currently supports the following configuration
- Swift 2.0
- XCode 7.0