3

I'm taking my first stab at the three20 iPhone framework and I can't seem to figure out how to change the background of a table cell to a UIImage instead of just the color. Can anyone help me out?

theChrisKent
  • 15,029
  • 3
  • 61
  • 62
kristy4life
  • 103
  • 1
  • 7

1 Answers1

11

You can set the backgroundColor of the cell's contentView with an image pattern like this:

cell.contentView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]];

This will work if the cell is a UITableViewCell or a three20 TTTableViewCell derivative (since they derive from UITableViewCell)

theChrisKent
  • 15,029
  • 3
  • 61
  • 62
  • But this produces Memory issues when using this PatternImage maximum in application. And also Crashes the application some times. – Bharathi Nov 28 '11 at 14:18
  • @Jasmine I'm not totally sure what you mean by PatternImage maximum. The method recommended above is a standard iOS call, if there is crashing or memory issues it is likely other code. However, an investigation using Instruments should shed some light. If it truly is a bug then please submit to Apple. If you have a new question concerning my answer or the method, please submit it as a new question. Thanks! – theChrisKent Nov 28 '11 at 17:36