您可以尝试使用徽章图标,并每秒将数字从 10 更新为 0。我假设您将这些方法放在 中AppDelegate
,但它们可以放在任何地方。尝试:
。H
@interface AppDelegate : NSObject <UIApplicationDelegate> {
int _countDownNumber;
NSTimer * _countDownTimer;
}
.m
- (void)updateTimer; {
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:_countDownNumber];
_countDownNumber--;
if(_countDownNumber < 0){
[_countDownTimer invalidate];
}
}
- (void)methodThatStartsTheCountDown; {
_countDownNumber = 10;
_countDownTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];
}
希望有帮助!