user3719120
user3719120

Reputation: 97

AsyncDisplayKit CellNode setting highlighted color

I'm using Async Display Kit to display cell nodes in an ASTableView. How can I set a custom color for the cell node's selected state. With normal tableView cells I would just override

in my cell implementation, but that method doesn't exist on ASCellNodes. Has anyone else encountered this problem and how did you solve it?

Upvotes: 0

Views: 784

Answers (1)

user1488696
user1488696

Reputation:

Assuming you've subclassed ASCellNode to create your own cells, you could just add your own setHighlighted method.

e.g.

- In Your ASCellNode Subclass

- (void)setHighlighted:(BOOL)highlighted {
    if (highlighted) {
        self.backgroundColor = [UIColor blueColor];
    } else {
        self.backgroundColor = [UIColor whiteColor];
    }
}

- In Your Delegate Implementation

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    MyNodeSubclass * node = (MyNodeSubclass *)[(ASTableView *)tableView nodeForRowAtIndexPath: indexPath];

    [node setHighlighted: YES];
}

Note: You'll need to maintain your own state in regards to which cells are selected/deselected

Upvotes: 1

Related Questions