0

我想要一个 uiview 的滚动动画。所以我正在为 mainscrollview 和 rollupboard 制作动画。所以在 viewDidLoad 我将这两个视图的框架设置为:

    dashRollUpStand=[[UIImageView alloc]initWithFrame:CGRectMake(0,346,320,0)];
    mainScrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(10,346,300,0)];

我也有这个 mainScrollView 的许多子视图。

现在我正在使用以下代码加载带有滚动动画的视图:

 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:1];
 [UIView setAnimationCurve:UIAnimationCurveLinear];

 [dashRollUpStand setFrame:CGRectMake(0,0,320,346)];
 [mainScrollView setFrame:CGRectMake(10,9,300,337)];
 [UIView commitAnimations];

此汇总动画在 iphone 中运行良好。但在 iphone 视网膜显示器上,这个动画一点也不流畅。那么我怎样才能使它在 iphone 视网膜显示中平滑。

4

2 回答 2

0

您是否有理由在 viewDidLoad 中添加视图并将它们移出屏幕?

在我看来,你应该这样做。下面的代码containerView包含您的视图的视图toView是您要翻转的视图,也是您要从fromView其翻转的视图。

[UIView transitionWithView:containerView
                  duration:1.0
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations:^{ 
                    [fromView removeFromSuperview]; 
                    [containerView addSubview:toView]; 
                }
                completion:NULL];

我还选择使用基于块的动画/过渡 API,这是自 iOS 4 以来推荐的方式。

编辑:

由于您实际上并没有转换视图,即使您的原始代码确实如此。您可以只使用普通的动画块

[UIView animateWithDuration:1.0
                 animations:^{
                     [dashRollUpStand setFrame:CGRectMake(0,0,320,346)];
                     [mainScrollView setFrame:CGRectMake(10,9,300,337)];
                 }
                 completion:NULL];
于 2012-06-08T07:14:15.127 回答
0

问题不在于您使用的动画类型,而更可能是您在视图之外拥有的动画。首先尝试确保动画视图中的子视图是不透明的,不透明是 UIView 的一个属性,但是如果视图的 alpha 小于 1,它会被覆盖。渲染系统需要更多的 cicles 来混合清晰的视图,如果你可以选择不透明的。

于 2012-06-08T09:58:25.110 回答