#pragma mark - timer
//创建timer 并开启timer
- (void)creatTimer{
if (!_timer) {
//保证timer只被开启一次
_timer = [NSTimer scheduledTimerWithTimeInterval:_time target:self selector:@selector(action_time) userInfo:nil repeats:YES];
}
}
-(void)action_time{
[self.scrollView setContentOffset:CGPointMake(2 * swidth, 0) animated:YES];
}
//开启timer
- (void)starTimer{
_timer.fireDate = [NSDate dateWithTimeIntervalSinceNow:2];//在现在的时间上加2秒,开始。
}
//暂停timer
- (void)pauseTimer{
_timer.fireDate = [NSDate distantFuture];
}
//停止timer
- (void)stopTimer{
[_timer invalidate];
_timer = nil;
}
网友评论