Protect private content from screen recordings and screen output.
Screen Recording / QuickTime Recording / External display output / AirPlay
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'RxScreenProtectKit'
end
Replace YOUR_TARGET_NAME and then, in the Podfile directory, type:
$ pod install
Add this to Cartfile
.
# Cartfile
github "AkkeyLab/RxScreenProtectKit"
Run this script to install it.
$ carthage update --platform iOS
If you use the example, please do the setup process with the shell script.
./setup.sh
Please import RxScreenProtectKit and RxSwift.
import RxScreenProtectKit
import RxSwift
import UIKit
By binding the target layer to isScreenRecord, mosaic processing is applied during screen recording or screen output. However, the layer must be compliant with CALayer.
final class ViewController: UIViewController {
@IBOutlet private weak var mainImageView: UIImageView!
private let bag = DisposeBag()
override func viewDidLoad() {
super.viewDidLoad()
self.rx.isScreenRecord
.bind(to: mainImageView.layer.rx.isMosaic)
.disposed(by: bag)
}
}
Parameter settings related to mosaic processing can be done from ScreenProtectKit.shared.config()
.
ScreenProtectKit
.shared
.config(rasterizationScale: 0.1,
minificationFilter: .trilinear,
magnificationFilter: .nearest)
Moreover, it can be easily implemented by using SPImageView. This is particularly useful when images are set asynchronously.
final class ViewController: UIViewController {
@IBOutlet private weak var mainImageView: SPImageView!
override func viewDidLoad() {
super.viewDidLoad()
DispatchQueue.main.asyncAfter(deadline: .now() + 5) { [weak self] in
self?.mainImageView.image = UIImage(named: "sample")
}
}
}
Also, by using SPLabel, you can easily implement character substitution during recording. All you need to do is set the text to be displayed during recording in protectText
.
final class ViewController: UIViewController {
@IBOutlet private weak var label: SPLabel!
override func viewDidLoad() {
super.viewDidLoad()
label.text = "This is the original text."
label.protectText = "Recording is prohibited!!"
}
}
You can temporarily disable this feature. In addition, it returns to the valid state by restarting the app.
isScreenRecord
will not flow while this setting is disabled.
When the value of this setting is changed, isScreenRecord
will flow only once. When changed to invalid, false will flow, and when changed to valid, the current recording status will flow.
ScreenProtectKit
.shared
.isValid = isValid
env | version |
---|---|
Swift | 5.x |
Xcode | 11.x |
iOS | 11.0 |
RxScreenProtectKit is available under the MIT license. See the LICENSE file for more info.