Prasad
Prasad

Reputation: 1924

Issue in setting the UITableViewCell borderlayer

I have tableview consisting of n number of rows(cells), i need to set the border layer for selected cell, for that i added this code on tableView: didSelectRowAtIndexPath: delegate method.

UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; //To get the particular cell

[cell.layer setBorderColor:[[UIColor colorWithRed:0.663 green:0.0 blue:0.373 alpha:1] CGColor]];

[cell.layer setBorderWidth:3.0];

Its working i mean its setting the border layer for selected cell. But the issue is if i click on one cell its setting the border layer for that cell, after i click on other cell its setting the border layer for other cell also, I need to remove the border layer for first one(I mean only the current selected cell only should contain the border layer)

Upvotes: 0

Views: 285

Answers (2)

The dude
The dude

Reputation: 7924

You could store the value of the index for the last selected row cell, and then set the border to its defaults inside didSelectRowAtIndexPath.

Upvotes: 0

rob mayoff
rob mayoff

Reputation: 385650

Turn off the border in tableView:didDeselectRowAtIndexPath:.

Upvotes: 1

Related Questions