I have a problem when setting the background color for a UIView. What I am doing is:

- (void) viewDidLoad {
    [super viewDidLoad];

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

but I am getting a black background color as shown below:

Incorrect Background Color - Illustrated

If I change the background to any another color it works. Any ideas about this ?

有帮助吗?

解决方案

Your view is working as intended. You are setting it to use a clear background color, which means exactly as it is named, clear, and you will see color and possibly other UI elements underneath your view. Think of it as placing clear plastic wrap (the view) on top of colored construction paper (the super view). If you wish to find where the black color is coming from, I would start with your root controller's view.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top