2
我有三个图像。它们应该像从动轮一样每4秒从右到左进行动画制作。如果用户拖动到第二张图像,那么在4秒钟后从第2 - 第3张开始滑动。如何实现这一点?使用nstimer在无限滚动视图中滑动图像
currntly我使用下面的代码,但它不按预期工作。
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(doAnimation) userInfo:nil repeats:YES];
-(void)doAnimation
{
if (currentPage) {
[self scrollFromCurrentpage];
return;
}
//CGPoint p=CGPointMake(count*320, 0);
if (count==3) {
count=0;
[_scrollView setContentOffset:CGPointMake(0, 0)animated:NO];
return;
}
count++;
[UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^
{
CGRect rect= CGRectMake(count*320, 0, 320, 352);
[_scrollView scrollRectToVisible:rect animated:NO];
}completion:^(BOOL finished)
{
}];
}
-(void)scrollFromCurrentpage
{
[UIView animateWithDuration:2.0 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^
{
CGRect rect= CGRectMake(currentPage*320, 0, 320, 352);
[_scrollView scrollRectToVisible:rect animated:NO];
currentPage=0;
}completion:^(BOOL finished)
{
}];
}
给我适当的执行 – MuraliMohan