Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <code>cell.selectionStyle = UITableViewCellSelectionStyleGray;</code> for changing the style of the cell selection. But here the <code>selectionStyle</code> only takes input of <code>UITableViewCellSelectionStyle</code> type.</p> <p>For changing Color you need to use Image. Use <code>selectedBackgroundView.image</code> property and Follow the <a href="http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html" rel="nofollow">tutorial Link</a></p> <p>Or you can also try </p> <pre><code> cell.selectedBackgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; cell.selectedBackgroundView.backgroundColor = [UIColor redColor]; </code></pre> <p><strong>EDIT:</strong></p> <p>OK I am updating code in case you have any other controls on the cell, then you can try below code.</p> <pre><code>// Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"myCellId"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; UIView *v = [[[UIView alloc] init] autorelease]; v.backgroundColor = [UIColor redColor]; // any color of your choice. cell.selectedBackgroundView = v; // After this line add all other controlls you are adding... } // Set up the cell... cell.textLabel.text = @"foo"; return cell; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload