2012-10-11 25 views
2

如下圖所示,我設置了表格的背景和其他一些樣式。以紅色突出顯示的索引是透明的。我如何將它設置爲像其他細胞一樣白色?iOS UITableView索引是透明的

enter image description here

+0

如果將附件視圖設置爲UITableViewCellAccessoryNone會發生什麼情況。配件消失了嗎? –

+0

右側的索引字母仍然有表格的背景,而不是純白色 –

回答

-1
its too much easy dude. 

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
    { 


     for(UIView *view in [tableView subviews]) 
     { 
      if([[[view class] description] isEqualToString:@"UITableViewIndex"]) 
      { 
      [view performSelector:@selector(setIndexColor:) withObject:[UIColor whiteColor]]; 

//give color which you want 
      } 
     } 



     static NSString *MyIdentifier = @"MyIdentifier"; 


    //go further with table cell design... 

    } 
+0

這是很糟糕的做法,可能會被Apple拒絕。如果蘋果在新的iOS版本中更改其TableView的內部實現,它將失敗。 – Vlad

1

可以使用指定的UITableView屬性:

tableView.sectionIndexColor = [UIColor brownColor]; 
tableView.sectionIndexBackgroundColor = [UIColor whiteColor]; 
tableView.sectionIndexTrackingBackgroundColor = [UIColor blueColor]; 

與底層的TableView層亂搞可能會拒絕您的應用程序,如果蘋果改變了他們的UITableView的實現可能會斷裂。