Change background of a UITableViewCell

I was asked this question by a co-worker on how to do this. My first answer was when you init the cell just set the backgroundColor but that did not work at all.

If you followed my other tutorials and have a custom UITableViewCell open that file and in the initWithFrame method you want the following

MyContentView.backgroundColor = [UIColor redColor];

Comments

3 Responses to “Change background of a UITableViewCell”

  1. Pete on September 22nd, 2008 4:04 am

    Is anything besides setting the background to another color? Like setting the background to a certain image? Just like themes…

  2. Alex Hunt on October 9th, 2008 7:51 am

    Did you manage to do this as I am trying to do the same.

    Existing code:
    self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];

    I am trying to replace the background colour with a picture.
    Thanks for any help

  3. giku on November 2nd, 2008 1:10 pm

    Just create new UIView, set it as table cell backgroundView and use backgroundColor of this UIView.

Leave a Reply