title: UITableView performance issues when adding UIViews to cell.contentView
body: <p>I am experiencing performance problems when using some subviews on my <code>UITableViewCells</code>. After I keep scrolling it eventually starts getting very slow. </p>
  
  <p>First step I am doing is creating a common <code>UIView</code> for every cell, essentially this is creating a white cell with a rounded effect on the cell with a shadow.  The performance for this seems to be normal so I don't think it's the culprit.</p>
  
  <p><img src="https://i.stack.imgur.com/tgHOL.png" alt="enter image description here"></p>
  
  <p>Here is the code I am using to do this:</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  {
          static NSString *NewsCellIdentifer = @"NewsCellIdentifier";
  
  
         NewsItem *item = [self.newsArray objectAtIndex:indexPath.row];
  
  
              UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NewsCellIdentifer];
  
              if (cell == nil)
              {
                  cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NewsCellIdentifer];
  
  
                  cell.contentView.backgroundColor = [UIColor clearColor];
  
                  UIView *whiteRoundedCornerView = [[UIView alloc] initWithFrame:CGRectMake(10,10,300,100)];
                  whiteRoundedCornerView.backgroundColor = [UIColor whiteColor];
                  whiteRoundedCornerView.layer.masksToBounds = NO;
                  whiteRoundedCornerView.layer.cornerRadius = 3.0;
                  whiteRoundedCornerView.layer.shadowOffset = CGSizeMake(-1, 1);
                  whiteRoundedCornerView.layer.shadowOpacity = 0.5;
  
                  [cell.contentView addSubview:whiteRoundedCornerView];
                  [cell.contentView sendSubviewToBack:whiteRoundedCornerView];
  
                  cell.layer.shouldRasterize = YES;
                  cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
                  cell.layer.opaque = YES;
  
                  cell.opaque = YES;    
              }
  
              [cell.contentView addSubview:[self NewsItemThumbnailView:item]];
  
              return cell;
  }
  </code></pre>
  
  <p>Here is the method that returns the thumbnail view of the graphic and text:</p>
  
  <pre><code>- (UIView *) NewsItemThumbnailView:(NewsItem *)item
  {
      UIView *thumbNailMainView = [[UIView alloc] initWithFrame:CGRectMake(10, 10, 50, 70)];
      UIImageView *thumbNail = [[UIImageView alloc] initWithImage:[UIImage imageNamed:item.ThumbNailFileName]];
      thumbNail.frame = CGRectMake(10,10, 45, 45);
      UILabel *date = [[UILabel alloc] init];
      date.frame = CGRectMake(10, 53, 45, 12);
      date.text = item.ShortDateString;
      date.textAlignment = NSTextAlignmentCenter;
      date.textColor = [BVColors WebDarkGrey];
      CGFloat fontSize = 10.0;
      date.font = [BVFont Museo:&amp;fontSize];
  
      date.opaque = YES;
      thumbNail.opaque = YES;
      thumbNailMainView.opaque = YES;
  
  
      [thumbNailMainView addSubview:thumbNail];
      [thumbNailMainView addSubview:date];
  
      return thumbNailMainView;
  }
  </code></pre>
  
  <p>The performance problem seems to be when I add the thumbnail view to the cell because when I comment that line out, I don't seem to have it. The thumbnail information is dynamic and will change with each cell. I would appreciate any advice on how I should do this without degrading the performance.</p>