开发者

small white gap when loading a background image as view

开发者 https://www.devze.com 2023-03-26 21:24 出处:网络
I have the following code in my viewWillAppear: - (void) viewWillAppear:(BOOL)animated{ self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@\"background.png\"]];

I have the following code in my viewWillAppear:

- (void) viewWillAppear:(BOOL)animated{
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
    [super viewWillAppear:animated];
}

However, why is it that when the first time it loads, I can see a white gap at the bottom of the screen? The background.png size is 640x960 pixel. This gap will disappear if I navigate to another view controller and go back to this view controller. This is the first view that is loaded when the app first launches. Anyone have any clue why this could happen?

Here's a screenshot:

small white gap when loading a background image as view

UPDATE:

It seems that 20px white gap is from the MainWindow.xib, not sure why we can still see it, while I already have added the view as a subview, it 开发者_Python百科should cover all. And why does it cover all after it gets back from another view?

Here's a sample project that you can download to show the issue


I am guessing you want to set the background view for your entire flow of views.

Just set

_window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"pause-background.png"]];

and

self.view.backgroundColor = [UIColor clearColor];
0

精彩评论

暂无评论...
验证码 换一张
取 消