Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift iOS- How to hide label then make it appear after a certain time period [duplicate]

I have a label that gets hidden when a button is pressed. After a certain time period like 60 secs I want the label to reappear. I'd assume I do that in viewDidAppear, How would i do that?

@IBOutlet weak var myLabel: UILabel!

override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
       //after 60 secs myLabel should reappear
       //self.myLabel.isHidden = false
    }


@IBAction func buttonTapped(_ sender: UIButton){
       self.myLabel.isHidden = true
}
like image 370
Lance Samaria Avatar asked Dec 05 '22 15:12

Lance Samaria


1 Answers

@IBAction func buttonTapped(_ sender: UIButton){
    self.myLabel.isHidden = true
    DispatchQueue.main.asyncAfter(deadline: .now() + 60) {
        self.myLabel.isHidden = false
    }
}
like image 107
Max Pevsner Avatar answered Jan 26 '23 00:01

Max Pevsner