Rana
Rana

Reputation: 247

can i use highlighted the table view cell without default blue color in objective c?

I doing a project where i need to use highlighted table view color not default.

Upvotes: 1

Views: 2286

Answers (2)

jiansihun
jiansihun

Reputation: 11

Try referring to this demo - maybe you could have a look at it and get some help.

Upvotes: 1

Can Berk Güder
Can Berk Güder

Reputation: 113300

Of course you can.

There are two methods to achieve this:

  1. Use UITableViewCell's selectedBackgroundView and selectedTextColor properties
  2. Subclass UITableViewCell and implement the drawInRect and setSelected:animated: methods

The latter option gives you more flexibility and much better performance, but it might be slightly harder if you haven't used CoreGraphics before.

UPDATE In response to the OP's comment:

Here's how you can use the selectedBackgroundView property:

UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
[bgView setBackgroundColor:[UIColor redColor]];
[cell setSelectedBackgroundView:bgView];
[bgView release];

I haven't tried this myself, but it should work.

Upvotes: 9

Related Questions