I am trying to change the label that you see in my screenshot that has a green background and says We Are Open.
I would like the bottom label to turn RED and say "Sorry we are closed" whenever the listed opening times have passed and then go back to GREEN and say "We Are Open" at the correct opening times.
I've managed to import date and time successfully into the top label but I'm not sure how do the bottom label.
Here is the code:
import UIKit
import Firebase
import FirebaseInstanceID
import FirebaseMessaging
class FirstViewController: UIViewController {
var timer = Timer()
@IBOutlet weak var timeLabel: UILabel!
@IBOutlet weak var openStatusLabel: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
FIRMessaging.messaging().subscribe(toTopic: "/topics/news")
self.timer = Timer.scheduledTimer(timeInterval: 1.0,
target: self,
selector: #selector(FirstViewController.tick),
userInfo: nil,
repeats: true)
}
@objc func tick() {
timeLabel.text = DateFormatter.localizedString(from: NSDate() as Date,
dateStyle: .medium,
timeStyle: .medium)
}
}