我想在两个视图之间创建动画,这就是我所做的:
两个视图包含相同的scrollView
,以及视图之间动画的目的是在scrollView的边缘之间创建动画。
所以这就是我所做的:
UIView *view1;
UIView *view2;
view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
view2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
self.scrollView1 = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 320)];
self.scrollView1.pagingEnabled = YES;
self.scrollView1.delegate = self;
[view1 addSubview:scrollView1];
[self.view addSubview:view1];
当scrollView
到达最后一帧时:
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
//here I verify when the last frame of the scrollView is loaded
if (self.scrollView1.contentOffset.x == self.view.frame.size.width*pathImages.count)
{
[view1 removeFromSuperview];
[self.scrollView1 scrollRectToVisible:CGRectMake(self.view.frame.size.width,0 ,self.view.frame.size.width, self.view.frame.size.height) animated:NO];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationOptionCurveEaseInOut forView:view2 cache:YES];
[view2 addSubview:scrollView1];
[self.view addSubview:view2];
[UIView commitAnimations];
}
}
问题是scrollView再次从第一个位置加载(应该如此)但没有动画 - 只是突然出现。 有人可以告诉我错误在哪里以及它的解决方案。谢谢你:)。
答案 0 :(得分:0)
尝试
UIViewAnimationCurveEaseInOut
而不是:
UIViewAnimationOptionCurveEaseInOut
通常,“UIViewAnimationOption *”与动画的新的,推荐的基于块的语法相关联。