title: how to set background image in uitableview cell in ios7?
body: <p>i am new to ios and now a days i am facing a little issue.When table view load then after scrolling up and down then background image show <a href="http://screencast.com/t/G4MK09D31K" rel="nofollow">like this</a> and here is my code</p>
  
  <p>Actually i want to show table as chat design. i not want to use any third party.</p>
  
  <pre><code>- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;}
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  return [_messages count];
  }
  
  
  - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  
  NSString *comment = [_messages objectAtIndex:indexPath.row];
  CGFloat whidt =  250;
  UIFont *FONT = [UIFont systemFontOfSize:18];
  NSAttributedString *attributedText =[[NSAttributedString alloc]  initWithString:comment  attributes:@  {      NSFontAttributeName: FONT }];
  CGRect rect = [attributedText boundingRectWithSize:(CGSize){whidt, MAXFLOAT}
                                             options:NSStringDrawingUsesLineFragmentOrigin
                                             context:nil];
  CGSize size = rect.size;
  return size.height +50;
  
  }
  
  
  - (UIFont *)fontForCell{
  return [UIFont boldSystemFontOfSize:18.0];
  }
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  
  
  static NSString *CellIdentifier = @"ChatListItem";
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (!cell) {
      cell = [[UITableViewCell alloc]
              initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
  
  }
  
  NSString *text = [_messages objectAtIndex:indexPath.row];
  CGSize constraint = CGSizeMake(250 , 20000.0f);
  UIFont *FONT = [UIFont systemFontOfSize:11];
  CGSize size = [text boundingRectWithSize:constraint options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:FONT }context:nil].size;
  
  cell.textLabel.frame = CGRectMake(10, 0, 250, MAX(size.height, 54.0f) + 20.0f);
  cell.textLabel.numberOfLines = 0;
  cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping;
  cell.textLabel.text = text;
  cell.textLabel.font = [UIFont systemFontOfSize:18];
  
  UIImage *img = [UIImage imageNamed:@"balloon_selected_right.png"];
  CGSize imgSize = cell.textLabel.frame.size;
  
  UIGraphicsBeginImageContext( imgSize );
  [img drawInRect:CGRectMake(0,0,250,imgSize.height)];
  UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  cell.textLabel.backgroundColor = [UIColor colorWithPatternImage:newImage];
  
  /*[cell.textLabel setText:[_messages objectAtIndex:indexPath.row]];
  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  cell.textLabel.text = [_messages objectAtIndex:indexPath.row];*/
  
  return cell;
  }
  </code></pre>
  
  <p>Thanks is advance!</p>