Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  2. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mycustomcell"];
  3. int r = [[data objectAtIndex:indexPath.row] intValue];
  4. UIImageView *img = (UIImageView *)[cell viewWithTag:2];
  5. img.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"some_img" ofType:@"png"]]];
  6. CGRect frame = img.frame;
  7. frame.size.width = r*16;
  8. img.frame = frame;
  9.  
  10. int n = img.frame.size.width;
  11. UILabel *label = (UILabel *)[cell viewWithTag:1];
  12. label.text = [NSString stringWithFormat:@"custom %d", n];
  13. [cell setNeedsDisplay];
  14. return cell;
  15. }
  16.  
  17. for (NSLayoutConstraint *constraint in img.constraints)
  18. {
  19. if (constraint.firstAttribute == NSLayoutAttributeWidth)
  20. constraint.constant = r*16;
  21. }
  22.  
  23. cell.imageWidthConstraint.constant = r*16;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement