iOS 8 UITableView background color appearance
Solution 1
try to "reset" the BackgroundColor to "Default" in the InterfaceBuilder (even if its already Default, you'll see a little color change)
this doesn't works with grouped style tableviews
UPDATE:
this worked for me
[[UIScrollView appearance] setBackgroundColor:[UIColor redColor]];
Solution 2
Clear color for TableViewCell not working in Tablet in XCode 6. The following workaround solve for me.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor redColor];
}
Solution 3
It appears that for iOS 8, at least for our circumstances, when we set a view's background color with a table in that view, we have to explicitly set the table and cell background colors to Clear in order for the desired color from the view to show. I suppose, with prior iOS versions, the cells were defaulted to transparent but that seems no longer the case.
Solution 4
Set cell background color to transparent in tableView:willDisplayCell:forRowAtIndexPath:
Solution 5
[UITableVIew backgroundColor] is not marked with UI_APPEARANCE_SELECTOR. Appearance proxies will only work if selector is marked with UI_APPEARANCE_SELECTOR.
Related videos on Youtube
HotJard
Updated on June 06, 2022Comments
-
HotJard almost 2 years
Xcode 6 beta 6, trying to change all UITableView's background colours in appearance proxy:
[[UITableView appearance] setBackgroundColor:[UIColor redColor]]
But seems that it doesn't work.
Steps to reproduce:
1 Create single view project
2 Add UITableView to ViewController in storyboard
3 Set delegates to view controller and change background in IB:
4 Add dynamic cell and configure data source:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return 2; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"Cell1Identifier" forIndexPath:indexPath]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60.f; }
5 In app delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [[UITableView appearance] setBackgroundColor:[UIColor redColor]]; return YES; }
6 Run app and watch incorrect colour:
Any suggestions how to fix it? Setting background color for every table doesn't look like good solution.
-
Yuvrajsinh over 9 yearsIt occurs only for iOS 8.0.x which was buggy, not producing in lower or greater version of 8.0.x and I think most of the users upgraded to 8.1 so not to worry at all:)
-
Maxim Pavlov over 9 yearsAccording to this question it seems to be a bug. rdar://18406065
-
Ben almost 9 yearsI still get the UITableView appearance background color issue in iOS 8.1.X and 8.2.X on physical device and simulator. However it works fine above. I have to keep a
[tableview setBackgroundColor: ]
programmatically. -
HotJard almost 9 yearspopei, The question is how to do it automatically in appearance proxy
-
-
Alex B over 9 yearsEven with default colour, it doesn't work right now.
-
HotJard over 9 yearsbut the problem is for grouped style tables
-
Prethen over 9 yearsThis did not work for me either. For some reason iOS 8 "broke" the ability to set the background color on the table view for us. Any other ideas?
-
Tony Adams over 9 yearsInteresting... I'm seeing it in all my 8.1 simulators.
-
matthias_buehlmann over 9 yearssetting appearance of UIScrollView allowed me to change the tableview background color - however, I did not manage to create a tableview with a transparent background (setting SetOpaque on UIScrollView appearance doesn't seem to do the trick)
-
Julian Vogels over 8 yearsThis shouldn't be the problem because UITableView inherits from UIView, which has a property backgroundColor marked with UI_APPEARANCE_SELECTOR.