#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;
}
NSTimer
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
推薦閱讀更多精彩內容
- 1. 關于NSTimer一些基本的知識,網上應該有很多講解,廢話不多少,直接上代碼 (1) 下面是簡單的實現代...