简体   繁体   English

UIView动画后失去背景

[英]UIView loses background when animated up

I am working on an iOS app and am having trouble with a really tall UIView (2400px tall). 我正在开发一个iOS应用,遇到了一个非常高的UIView (2400像素高)的麻烦。 The UIView contains a really long form that's been broken down into 5 parts. UIView包含一个很长的表格,该表格分为5个部分。 As the user completes one part of the form, I would like to slide the UIView up to reveal the next part. 当用户完成表单的一部分时,我想向上滑动UIView来显示下一部分。 I present the UIView modally. 我以模态形式呈现UIView

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. 我遇到的问题是,当我向上滑动UIView ,背景与第一部分中的对象一起向上滑动,而下一部分则具有清晰的背景。 The code I use to slide the UIView is: 我用来滑动UIView的代码是:

- (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. 真的很高的UIView中的所有对象都可以正常滑动,我只是失去了背景色。 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. 无论如何,您可能应该使用禁用滚动的UIScrollView而不是非常长的UIView。 You can then simply animate the contentOffset property to scroll the controls up, but the scrollview itself can simply be screen-sized. 然后,您可以简单地设置contentOffset属性的动画以向上滚动控件,但是scrollview本身可以只是屏幕大小。

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. 我强烈建议您为真正的长视图创建IBOutlet,而不是使用self.view.frame,以便代码看起来像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. 现在,我敢打赌,您正在制造错误的观点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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