您不能淡出 UIView (滚动条)并同时淡入同一个视图...
你可以只使用不同的 UIViews ......
你可以做的是:
1)fadeOut当前位置的滚动条(到背景)
2)当滚动条不可见时,将其移动到正确的位置(没有动画)
3)从后台淡入滚动条
就像是:
// START FIRST PART OF ANIMATION
[UIView animateWithDuration:0.5 delay:0.0 options: options:UIViewAnimationOptionTransitionCrossDissolve|UIViewAnimationOptionAllowAnimatedContent animations:^{
pagingScrollView.alpha = 0;
} completion:^(BOOL finished) {
// FIRST PART ENDED
// MOVE SCROLLER (no animation)
pagingScrollView.contentOffset = CGPointZero;
// START SECOND PART OF ANIMATION
[UIView animateWithDuration:0.5 delay:0.0 options: options:UIViewAnimationOptionTransitionCrossDissolve|UIViewAnimationOptionAllowAnimatedContent animations:^{
// fadeIn - animated
pagingScrollView.alpha = 1;
} completion:^(BOOL finished) {
// ANIMATION ENDED
[self refreshPages];
}];
}];
新编辑:
感谢 amadour,他的评论教会了我一些东西,
我希望他能添加他自己的答案,我会投票给他
无论如何,要回答乔伊原始问题:
我得到了正确的动画,只是将 contentOffset 设置移出动画块,并删除 UIViewAnimationOptionAllowAnimatedContent (不是真的需要),并将 pagingScrollView 作为参数传递给 transitionWithView
这对我有用:
pagingScrollView.contentOffset = CGPointZero;
[UIView transitionWithView:pagingScrollView duration:3.0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
// pagingScrollView.contentOffset = CGPointZero; // move up, outside of animation block
} completion:^(BOOL finished) {
NSLog(@"-->> END amimation");
[self refreshPages];
}];