使用 NSTimer 创建倒计时
我有一个 int 值,表示事件的倒计时(正在显示的视图)。目前,我这样做:
- (void) buttonTapped:(id)sender {
[self performSelector:@selector(displayView) afterDelay:countdownValue];
}
我想做的是以下...
当点击按钮时,将导航栏的色调颜色按比例更改为红色,黄色,绿色,直到倒计时到期,然后显示视图。
例如,如果我的倒计时是 3 秒,则每种颜色一秒,如果是 5 秒,则每种颜色 1.666。
我可以使用 NSTimer 来安排这个吗?
显示视图后,计时器需要失效。
谢谢
I have a int value representing a countdown to an event (view being displayed). Currently, i do this:
- (void) buttonTapped:(id)sender {
[self performSelector:@selector(displayView) afterDelay:countdownValue];
}
What I would like to do is the following...
When the button is tapped, change the tint colour of my navigation bar to red, yellow, green proportionally, until the countdown expires, then display the view.
So for example if my countdown is 3 seconds, one second for each colour, if it is 5 seconds, 1.666 for each colour.
Can I use an NSTimer to schedule this?
After the view is displayed the timer would need invalidating.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
和回调(在那里做任何你想做的事情):
And callbacks (do whatever you want there):