我有几个手势识别器可以左右滑动图像或 vv,具体取决于滑动的方向。但我希望动画更流畅。到目前为止,这是我的代码:
-(void)swipeNext:(id)sender{
//0 Get the currentview as referenced by pageControl
UIImageView *oldView = [views objectAtIndex:currentViewIndex];
//MOVE ON TO NEW VIEW
currentViewIndex ++;
NSLog(@"left swiped - currentViewIndex:%d", currentViewIndex);
UIImageView *newView = [views objectAtIndex:currentViewIndex];
//NSLog(@"views objectAtIndex = %@",[views objectAtIndex:[self.pageControl currentPage]]);
//1 Animate out the old view
newView.frame = oldView.frame;
newView.center = CGPointMake(oldView.center.x + CGRectGetWidth(oldView.frame), oldView.center.y);
[oldView.superview addSubview: newView];
[UIView animateWithDuration:1.0
delay: 0.0
options: UIViewAnimationOptionCurveEaseIn //UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
animations:^{
newView.center = oldView.center;
oldView.center = CGPointMake(oldView.center.x - CGRectGetWidth(oldView.frame), oldView.center.y);
}
completion:nil];
}
我想让它快一点。我已经发布了对我试图模仿的应用程序的引用,DunkinDonuts(Dunkin Donuts 应用程序使用什么样的视图控制器)并且他们似乎使用了 UIPageControl,我一开始尝试使用但无法确定滑动的方向(如何使用 UIPageControl 从左到右为 UIImageView 设置动画?),所以我切换到了 Gestures。但是,如果您看到他们的应用程序,则滑动速度会更快。