UITableView Index Index Background?

enter image description here

How to get rid of white in the section index? When I completely delete the partition index, it looks like this: enter image description here

So is the partition index the cause of the problem? But when I create an iPhone version with the same exact code, I get the following:

enter image description here

Nevermind, I found a solution. Too long to print, but I fixed it. This is due to autosave masks.

+4
source share
5 answers

The problem is with the autoresist mask in the Custom Cell objects that I used (using the interface builder to create custom cells). Check them out first.

0
source

There are delegates in the table view to edit the font color of the section as well as the background color.

if ([self.tableView respondsToSelector:@selector(setSectionIndexColor:)]) { self.tableView.sectionIndexColor = [UIColor whiteColor]; self.tableView.sectionIndexBackgroundColor = [UIColor colorWithWhite:0.3 alpha:0.7]; } 
+2
source

also one of the solutions:

 - (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath { // Some code here UIView *backgroundView = [[UIView alloc] initWithFrame:cell.frame]; backgroundView.backgroundColor = [UIColor redColor]; cell.backgroundView = backgroundView; } 
+1
source

Despite the fact that you found the answer, as the next note that in the new iOS you can now change the section index properties, look at my answer here

How to change the font color of section headings

in your case use sectionIndexBackgroundColor to change the background color

 @property(nonatomic, retain) UIColor *sectionIndexBackgroundColor 
+1
source

You cannot - section indices cannot be styled (with the exception, perhaps, of really hacking something, like scrolling through a hierarchy of views to find an index index, and then somehow change it).

Either create your own index by placing buttons in front of the table view, or live without an index.

0
source

Source: https://habr.com/ru/post/1394728/


All Articles