In the iOS SDK, the highlighted background color for UITableViewCell only supports two colors, uitableviewcellselectionstyleblue and Uitableviewcellselectionstylegray.
So how do you customize this color? One idea is to set the background color of the cell you want when the cell is clicked, and reset the cell back to the original background color when the click is released, so that you can achieve the desired effect.
The following is the implementation-specific code:
-(void) DrawRect: (cgrect) rect { if (self.highlighted) { = [Uicolor Colorwithhexstring:@ "0x383838"]; } Else { = [Uicolor clearcolor]; } } -(void) sethighlighted: (BOOL) highlighted animated: (BOOL) animated { [super Sethighlighted:highlighted animated:animated]; [Self setneedsdisplay]; }
1. Inheriting UITableViewCell
2. Rewrite the above two methods.
When the user clicks or releases, the system will call the following method to change the cell's highlighted background color.
-(void) sethighlighted: (BOOL) highlighted animated: (BOOL) animated
[IOS Dev] Custom (rewrite) UITableViewCell Highlight background color