Alexey
Alexey

Reputation: 7247

Why does the default background of the uivew is black in IB xcode?

When i set the default background for the view (the view is used as a header for the table) in IB it becomes black but when I run the app on a simulator it has the default color of the uitableview background.

When i set the default color to yellow for example it is always yellow for both IB and simulator.

why the default background color is black in IB and gray with stripes in a simulator?

Upvotes: 4

Views: 4757

Answers (1)

Levi
Levi

Reputation: 2113

Because the Interface Builder in Xcode has bugs. I assume you mean you are setting the background color to the "default" option?

I have run into several similar bugs with background color, sometimes it even sets the background color of an element that isn't supposed to have a background color. What I usually do is right click on the xib or storyboard file and Open As Source Code. Then find my element and carefully delete the background property (make a backup of the file if you are concerned about accidentally breaking the complex xml file structure). Then open it as Interface Builder again and it usually figures things out.

Or, worst case, I delete the problem element or view and recreate it.

Edit: it also occurred to me that the default color could be the clear color, in which case, the texture is showing through the view, not being drawn as the view's background, and interface builder chooses black because A) it doesn't know what the view will be drawn on top of and/or B) the view or parent view is marked as opaque or something to that effect.

Upvotes: 5

Related Questions