You can change the highlight Color in several ways.
- Change the selectionStyle property of your cell to UITableViewCellSelectionStyleGray. If you change it to , it will be gray.
- Change the selectedBackgroundView property. Actually what creates the blue gradient is a view. You can create a view and draw what ever Color you like, and use the view as the background of your table view cells.
- You can also set None UITableViewCellSelectionStyleNone to it. that means there will be no Selection Style.
Write below code into -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
This is to make it gray.
if(cell == nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.backgroundColor = [UIColor clearColor];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
}
if(cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.backgroundColor = [UIColor clearColor];
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor greenColor];
[cell setSelectedBackgroundView:bgColorView];
}
You can also set RGB color to it just like below code.
if(cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
cell.backgroundColor = [UIColor clearColor];
UIView *bgColorView = [[UIView alloc] init];
bgColorView.backgroundColor = [UIColor colorWithRed:255.0/256.0 green:139.0/256.0 blue:15.0/256.0 alpha:1];
[cell setSelectedBackgroundView:bgColorView];
}
Thanks & Regards
Angel AppTech
No comments:
Post a Comment
Note: only a member of this blog may post a comment.