简体   繁体   中英

UIView loses background when animated up

I am working on an iOS app and am having trouble with a really tall UIView (2400px tall). The UIView contains a really long form that's been broken down into 5 parts. As the user completes one part of the form, I would like to slide the UIView up to reveal the next part. I present the UIView modally.

The problem that I am having is that when I slide up the UIView , the background slides up along with the objects in the first section and the next section is left with a clear background. The code I use to slide the UIView is:

- (IBAction)slideUp {   
    // Slide the view up the screen to reveal the next section
    CGRect frame = self.view.frame;
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1.75];
    frame.origin.y = -480;
    self.view.frame = frame;
    [UIView commitAnimations];
}

All of the objects in the really tall UIView slide up fine, I'm just losing my background color. Any idea why?

Thanks!

Is your background being rendered by some sort of "background view" that's sized to fit the screen?

In any case, you should probably use a UIScrollView with scrolling disabled instead of a really long UIView. You can then simply animate the contentOffset property to scroll the controls up, but the scrollview itself can simply be screen-sized.

Instead of using self.view.frame, i would highly recommend you create an IBOutlet for the really long view so that the code looks like self.longView.frame.

This will help making it clear which views you are working with.

Right now i am betting that you are animating the wrong view.

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