xcode 推送视图时更改iOS应用程序的背景颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13866334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:18:41  来源:igfitidea点击:

Change Background Color of iOS App When Pushing Views

iosxcodeimagetransitionpushviewcontroller

提问by user717452

In my app, I use a navigation controller to switch between different views. Each of my views has an image for a background, but when I go from one to another, a little bit of white shows up in between them while transitioning. Is there a way to change that?

在我的应用程序中,我使用导航控制器在不同视图之间切换。我的每个视图都有一个背景图像,但是当我从一个视图转到另一个视图时,在过渡时它们之间会出现一点白色。有没有办法改变它?

In the Table View Class I have this in the viewDidLoad:

在表视图类中,我在 viewDidLoad 中有这个:

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"parchment.png"]];
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.backgroundView = imageView;
    [imageView release];

In the detail view I have just a standard loadrequest for an HTML. The HTML itself has the code for the parchment paper to be a background image. Here is what they look like:

在详细视图中,我只有一个标准的 HTML 加载请求。HTML 本身具有将羊皮纸作为背景图像的代码。这是它们的样子:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

But, going back from the detail view with the verses to the table view, I get this: enter image description here

但是,从带有经文的详细视图返回到表视图,我得到了这个: 在此处输入图片说明

回答by Salman Zaidi

In your:

在你的:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

method of AppDelegate. assign background color to window like this:

AppDelegate 的方法。像这样为窗口分配背景颜色:

self.window.backgroundColor = [UIColor blackColor]; // or anycolor

回答by Mick MacCallum

Have you tried changing the background color property of the view?

您是否尝试过更改视图的背景颜色属性?

[[self view] setBackgroundColor:[UIColor redColor]];

回答by user717452

The issue was in the viewWillDisappear of the web view controller. It was set to change webpage to about:blank page, which made it white. I got rid of that code, and it worked fine.

问题出在 web 视图控制器的 viewWillDisappear 中。它被设置为将网页更改为 about:blank 页面,使其变为白色。我摆脱了那个代码,它工作得很好。

回答by Moxy

Try to set the background color of the navigation controller's view.

尝试设置导航控制器视图的背景颜色。

In your navigation controller's root view controller (I guess it's the table view controller)

在您的导航控制器的根视图控制器中(我猜它是表视图控制器)

self.navigationController.view.backgroundColor = // any color ;