Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios7 UITableViewCell selectionStyle won't go back to blue

Xcode 5.0, iOS 7 and updating an existing app. UITableView selected row is now gray, not blue.

From what I've read they changed the default selectionStyle to gray. But "Blue" is still an option in IB and UITableViewCellSelectionStyleBlue still exists. Checking out the new HIG, it doesn't look like they removed the blue and the "Settings" app still using blue cell selection.

I've tried setting the value in IB and in code, but no luck. Any ideas on what I need to do to get the blue selection style back?

like image 846
DBD Avatar asked Sep 13 '13 19:09

DBD


1 Answers

There is only one selectionStyle in iOS7, to change you need to do this manually like below:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {      ....     UIView *bgColorView = [[UIView alloc] init];     bgColorView.backgroundColor = [UIColor colorWithRed:(76.0/255.0) green:(161.0/255.0) blue:(255.0/255.0) alpha:1.0]; // perfect color suggested by @mohamadHafez     bgColorView.layer.masksToBounds = YES;     cell.selectedBackgroundView = bgColorView;     ....     return cell; } 
like image 120
Tarek Hallak Avatar answered Oct 04 '22 22:10

Tarek Hallak