0

Is there an easy way to change the border color of a UITableViewCell? I tried

self.backgroundView.layer.borderColor = [UIColor greenColor].CGColor;
self.backgroundView.layer.borderWidth = 1.0f;

but this seems to add a layer. My platform is iOS 5.0

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
Denis
  • 61
  • 1
  • 10

1 Answers1

0

To solve your problem you can do something like this image for your TableViewCell : enter image description here

Firstly, you have your cell with your Label for example.

Next, you can add a backgroundView (the white view with red bottom border)

and, you can add a selectedBackgroundView (the blue view with the purple bottom border).

Don't forget to link the backgroundView and the selectedBackgroundView.

The border is defined by a UIView and so you can chose the height of this border (1px is the good appropriate value for a border).

After that, you can deselect the separator for your TableView :

enter image description here

With this technical you can chose and adapt your interface with your custom border and, if you add an IBOutlet for the UIView border, you can add some code for change the color.

Jordan Montel
  • 8,227
  • 2
  • 35
  • 40