bfeher / BFPaperTableViewCell

A subclass of UITableViewCell for iOS inspired by Google's Paper Material Design.
MIT License
368 stars 44 forks source link

Segue back and deselect cell animation like in default UITableViewCell #3

Closed artworkad closed 10 years ago

artworkad commented 10 years ago

Using UITableViewCell you get this effect when you first click on a cell, segue to another view and move back again. The cell is still selected and the selection state fades out animated. You can see it in the iPhone Settings app very clearly.

I noticed that BFPaperTableViewCell is not behaving that way. Are there plans to implement that?

bfeher commented 10 years ago

Hi ArtworkAD!

Because BFPaperTableViewCells do their own background highlighting, in their constructor I purposely set their selectionStyle to UITableViewCellSelectionStyleNone which is causing the behavior you describe.

If you are ok with the highlight looking a bit different, you can set cell.selectionStyle = UITableViewCellSelectionStyleDefault; in cellForRowAtIndexPath, or wherever you setup your cells, to bring back this behavior (similar to the Settings app).

If you are talking about adding a feature to BFPaperTableViewCell so that it's background fade remains upon selection and goes away on deselection, well I never thought of this. I'm not technically selecting or highlighting the cell, just drawing a layer on it. Also, cell selection is often handled by the tableView, not the cell itself.

However you have sparked my interest; I suppose I could override setSelected, setHighlighted, and prepareForReuse to imitate this kind of effect.

I'll let you know if I get this working nicely.

artworkad commented 10 years ago

Thank you for this great explanation. I think UITableViewCellSelectionStyleDefault will be ok for me.

bfeher commented 10 years ago

Hello again,

I've pushed version 1.3.0 which now has two new properties: CGFloat backgroundFadeAlpha & BOOL letBackgroundLinger (default YES).

Also now you no longer need to set cell.selectionStyle = UITableViewCellSelectionStyleDefault; because the background will linger until the cell is de-selected. You should find that it behaves just like the standard UITableViewCell in a standard UITableViewController.

Please let me know if you find any bugs. Thanks for suggesting this feature!

artworkad commented 10 years ago

@bfeher this is awesome, thank you :+1: