Auto dismiss (dispatch_after)
abousaif56 opened this issue · comments
I am a beginner in swift, I used the easytipview its is really good... I have installed the easytipview in my project and is working fine, no problems... I click on it and it goes away..
But also I need to dismiss it automatically (say after 5 seconds) as mentioned in the issue #48 (Auto dismiss option? #48) by rebenquito.. can anyone please explain into more details for me how to use the dispatch_after recommended by the owner as he didn't elaborate , I tried many ways but was unsuccessful.. I use swift 4, appreciate your help. thanks
Use a timer to do this.
private func setupTimer() {
// Weak self, won't dismiss tool tip
Timer.scheduledTimer(withTimeInterval: showForSeconds, repeats: false) { _ in
self.easyTipView.dismiss()
}
}
You can't use dismiss() on the class directly, it is an instance method, so declare an instance of EasyTipView, then you can call all show and dismiss methods that you need. e.g.
var toolTip = EasyTipView()
// Do your stuff with the tool tip
toolTip.dismiss()