Note that there are some explanatory texts on larger screens.

plurals
  1. POCustom UITableViewCell with drawRect + normal blue selection
    primarykey
    data
    text
    <p>I have a custom UITableViewCell. All the drawing is done in the drawRect: method and no subviews are added. The drawing works fine and the scroll speed is good. But the problem is with the selected cells. I want the selection to behave like it would normally:</p> <ul> <li>Blue gradient selection color</li> <li>Inverted text color</li> <li>Animated deselection</li> </ul> <p>I have not been able to achieve all three.</p> <p><strong>First attempt:</strong><br> Set selectionStyle = UITableViewCellSelectionStyleNone and do the selection color in the drawRect method. With this method, I am able to achieve the first two things, but the deselection is instant. So one second it is selected blue, the next second it is deselected. I do not get the nice fade-out.</p> <p><strong>Second attempt:</strong><br> selectionStyle = UITableViewCellSelectionStyleBlue With this method my cell is all gradient blue when selected. The text I have is not visible. The fade-out works nicely, though.</p> <p><strong>Third attempt:</strong><br> Set selectionStyle = UITableViewCellSelectionStyleBlue and also set selectedBackgroundView to a UIView where I set the backgroundColor to a transparent blue. Here the problem is that the selectedBackgroundView (despite the name) is drawn on top of my normal content. So if the selectedBackgroundView is not transparent, I cannot see the text. And if it is transparent, I can see the text, but the selection color gets "faded" and does not look right.</p> <p><strong>What would be the correct way of achieving all three bullet points?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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