简体   繁体   中英

UIView resize and translate animation does not animate subviews correctly

I am using a UIView animation to resize and translate a view containing multiple subviews. The animation for the parent view happens perfectly; however, the subviews exhibit strange behaviour. When the animation begins, the subviews are immediately resized and then moved to their final position.

For example, if the duration and delay of the animation was five-seconds, as soon as the animation was called, the subviews would move to the desired end-of-animation values. After five-seconds, the superview would be resized and translated to the desired.

My code for the animation is:

[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;
    }
}];

Any ideas?

Note: rightPaneContainerView contains the view of a UIViewController that is a child of the view controller that calls this animation.

I managed to solve the problem. The content mode for some of the views was set to Left. When the animation started, the views would jump the left, and then be animated to the desired end-of-animation value.

An amateur mistake. Thanks everyone who took a look.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM