我有一些代码以不同的部分(小时、分钟、秒)显示时间。
- (void)viewDidLoad
{
[self updateTime];
[super viewDidLoad];
hourFormatter = [[NSDateFormatter alloc] init];
hourFormatter.dateFormat = @"HH";
minuteFormatter = [[NSDateFormatter alloc] init];
minuteFormatter.dateFormat = @"mm";
secondFormatter = [[NSDateFormatter alloc] init];
secondFormatter.dateFormat = @"ss";
}
- (void)updateTime {
[updateTimer invalidate];
updateTimer = nil;
currentTime = [NSDate date];
NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
[timeFormatter setTimeStyle:NSDateFormatterMediumStyle];
hourLabel.text = [hourFormatter stringFromDate: currentTime];
minuteLabel.text = [minuteFormatter stringFromDate: currentTime];
secondLabel.text = [secondFormatter stringFromDate: currentTime];
updateTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
}
我想要三个栏(小时、分钟、秒)随着时间的增加而上升。就像这个 cydia 锁屏调整: http: //patrickmuff.ch/repo/
编辑:我应该补充一点,我对 Objective-C 非常陌生并且非常缺乏经验,因此非常感谢任何提示/帮助!