Add to AppDelegate'sapplication(_:didFinishLaunchingWithOptions:) following code:
```swift
CTXTutorialEngine.shared.addTutorials { error in
if let error = error {
//handle error
}
}
CTXTutorialEngine.shared.start()
2. Add `CTXTutorialConfig.json` to your project with content:
And your ViewCotroller's code should looks like this:
``` swift
import CTXTutorialEngine
class ViewController: CTXTutorialViewController {
private let myView: UIView = ...
private let engine = CTXTutorialEngine.shared
override func viewDidLoad() {
super.viewDidLoad()
myView.accessibilityIdentifier = "myView"
view.addSubview(myView)
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
engine.observe(self, contentType: .dynamic)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
engine.unobserve(self)
}
}
Default Hint View will appear and it will be plain white with black text and gray buttons,
but if you wan to alter appearance you should set parameters of CTXTutorialEngine.shared.appearance.
You can do it at app start or on each step of your tutorial by conforming your ViewController to CTXTutorialEngineDelegate:
CTXTutorialEngine
CTXTutorialEngine is library provides ability to display hints or even tutorials to onboard users into your awesome app.
Features
Requirements
Installation
CocoaPods
Carthage
In your
Cartfile
, addSwift Package Manager
don’t forget to do
import CTXTutorialEngine
Quick start
You want to show hint view for some UIView.
AppDelegate's
application(_:didFinishLaunchingWithOptions:)
following code: ```swift CTXTutorialEngine.shared.addTutorials { error in if let error = error { } }CTXTutorialEngine.shared.start()
{ “tutorials”: [ { “id”: “0”, “name”: “My view tutorial”, “events”: [ { “CTXTutorialViewsShownEvent”: { “event”: { “steps”: [ { “text”: “Hello world!”, “accessibilityIdentifier”: “myView” } ] } } } ] } ] }
Default Hint View will appear and it will be plain white with black text and gray buttons, but if you wan to alter appearance you should set parameters of
CTXTutorialEngine.shared.appearance
. You can do it at app start or on each step of your tutorial by conforming yourViewController
toCTXTutorialEngineDelegate
:and don’t forget to set
engine.delegate = self
inviewDidAppear(_:)
Advanced setup
TODO
Contribute
We would love you for the contribution to CTXTutorialEngine, check the
LICENSE
file for more info.Special thanks to:
Eugene Cherkasov (https://github.com/johnnie-che)
License
MIT license. See the LICENSE file for details.