Alex Stone
Alex Stone

Reputation: 47348

iOS - how to implement custom table view cell selection/unselection?

I'm working with a UITableView, and as far as I understand it has grey or blue selection of rows. Is there a way to override UITableView cell selection behavior (define a "selected" style)?

If there is not, would a vertical collection view work as an imitation of a table view with custom selection?

Upvotes: 0

Views: 212

Answers (1)

Steve Rosenberg
Steve Rosenberg

Reputation: 19524

According to the UITableViewCell Class reference, you are limited to:

UITableViewCellSelectionStyle The style of selected cells.

Declaration SWIFT

enum UITableViewCellSelectionStyle : Int {
    case None
    case Blue
    case Gray
    case Default
}

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/#//apple_ref/swift/enum/UITableViewCellSelectionStyle

So you would have to develop your own custom action on selection to change the background color.

Upvotes: 1

Related Questions