Reputation: 793
I have implement a side out menu for my currently developing ios application.There I used a UITableViewController as my menu and I want to highlight the menu item selected. I have done the highlighting thing and the problem is when I select one of those menu items, up and down borders of the table cell get visible.
This is my side menu and look at the selected table cell(menu item). there are up and down cell borders or something like that.
This is my code that I used to highlight the selected cell
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
[self setCellColor:[UIColor colorWithRed:0.192 green:0.192 blue:0.192 alpha:1] ForCell:cell]; //highlight colour
}
- (void)tableView:(UITableView *)tableView didUnhighlightRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
[self setCellColor:[UIColor colorWithRed:0.239 green:0.239 blue:0.239 alpha:1] ForCell:cell]; //normal color
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
[self setCellColor:[UIColor colorWithRed:0.192 green:0.192 blue:0.192 alpha:1] ForCell:cell];
}
- (void)setCellColor:(UIColor *)color ForCell:(UITableViewCell *)cell {
cell.contentView.backgroundColor = color;
cell.backgroundColor = color;
//cell.backgroundView.backgroundColor = color;
}
I already tried to change the selected cell border color in different different ways but all those were not successful.
Can someone please help me to get this solved.
Upvotes: 3
Views: 589
Reputation: 3358
You just need to set the "selection" property of UITableViewCell to "none" and add the following code to your controller. see screenshot its working.
Code:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = (UITableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
[self setCellColor:[UIColor colorWithRed:0.239 green:0.239 blue:0.239 alpha:1] ForCell:cell]; //normal color
}
Upvotes: 1
Reputation: 487
try this. Select tableview and go to Attribute Inspector. In separator just set the table view separator color to clear color.
Upvotes: 2
Reputation: 8924
Try this.
Select tableview and go to Attribute Inspector.
Find the property Separator and make it Default to None.
And also set the color to Clear Color.
I hope it will work for you...good luck !! :)
Upvotes: 0