@IBOutlet var countDownLabel: UILabel! var count = 10 override func viewDidLoad() { super.viewDidLoad() var timer = Timer.scheduledTimer(timeInterval: 0.4, target: self, selector: #selector(UIMenuController.update), userInfo: nil, repeats: true) } func update() { if(count > 0) { countDownLabel.text = String(count--) } }
How can I make a countdown with NSTimer?
How can I make a countdown with an NSTimer using Swift?
stackoverflow.com
'Programming > Swift' 카테고리의 다른 글
Choosing Between Structures and Classes (0) | 2021.01.14 |
---|---|
round number to 2 decimal places (0) | 2021.01.13 |
Immutable value X is never used consider replacing with '_' (0) | 2021.01.08 |
iOS: Tracking Visited Locations (0) | 2021.01.08 |
Article: Choosing the Location Services Authorization to Request (0) | 2021.01.08 |