Neal L
Neal L

Reputation: 4339

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!

Upvotes: 0

Views: 205

Answers (2)

AlvinfromDiaspar
AlvinfromDiaspar

Reputation: 6834

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.

Upvotes: 0

Lily Ballard
Lily Ballard

Reputation: 185831

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.

Upvotes: 1

Related Questions