一些应用中,为了和主题风格保持一致,需要隐藏了ipad或者iphone中的statusBar ([UIApplication sharedApplication].statusBarHidden = YES ; ),而自己写时间条。在时间条中,时间是一秒中刷新一次。
1、主要是用到一下的函数方法:
NSTimer *timer = [NSTimerscheduledTimerWithTimeInterval:1target:self
selector:@selector(updateDate)userInfo:nilrepeats:YES];[timer fire];
其中1代表的是刷新间隔的时间为1秒。
updateDate方法是具体更改显示时间。
2、updateDate方法涉及到的内容:
- (void)updateDate{
[selfgetCurrentTime:@"YYYY":5:yyyy];
[selfgetCurrentTime:@"MM" :60:MM];
[selfgetCurrentTime:@"dd" :95:dd];
[selfgetCurrentTime:@"hh" :140:hh];
[selfgetCurrentTime:@"mm" :165:mm];
[selfgetCurrentTime:@"ss" :190:ss];
}
其中:getCurrentTime方法是具体得到当前的各个时间的显示格式,显示label的横坐标,和显示的