UIView调整大小并翻译动画不会正确地为子视图设置动画

时间:2011-12-12 07:14:41

标签: iphone objective-c ios xcode

我正在使用UIView动画调整大小并翻译包含多个子视图的视图。父视图的动画完美发生;但是,子视图表现出奇怪的行为。动画开始时,子视图会立即调整大小,然后移动到最终位置。

例如,如果动画的持续时间和延迟为5秒,则一旦调用动画,子视图将移动到所需的动画结束值。五秒后,superview将调整大小并转换为所需的。

我的动画代码是:

[UIView animateWithDuration:0.5 animations:^{
    if (UIDeviceOrientationIsLandscape(self.interfaceOrientation)) {
        self.leftPaneView.frame = leftPaneLandscapeFrame;
        self.rightPaneContainerView.frame = rightPaneLandscapeFrame;
    }
    if (UIDeviceOrientationIsPortrait(self.interfaceOrientation)) {
        CGFloat offset = 300;
        self.leftPaneView.frame = CGRectOffset(leftPanePortraitFrame, -offset, 0);
        self.rightPaneContainerView.frame = rightPanePortraitFrame;
    }
}];

有什么想法吗?

注意:rightPaneContainerView包含一个UIViewController的视图,它是调用此动画的视图控制器的子视图。

1 个答案:

答案 0 :(得分:7)

我设法解决了这个问题。某些视图的内容模式设置为Left。动画开始时,视图将向左跳转,然后动画化为所需的动画结束值。

业余的错误。谢谢所有看过的人。