Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"mycustomcell"];
- int r = [[data objectAtIndex:indexPath.row] intValue];
- UIImageView *img = (UIImageView *)[cell viewWithTag:2];
- img.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"some_img" ofType:@"png"]]];
- CGRect frame = img.frame;
- frame.size.width = r*16;
- img.frame = frame;
- int n = img.frame.size.width;
- UILabel *label = (UILabel *)[cell viewWithTag:1];
- label.text = [NSString stringWithFormat:@"custom %d", n];
- [cell setNeedsDisplay];
- return cell;
- }
- for (NSLayoutConstraint *constraint in img.constraints)
- {
- if (constraint.firstAttribute == NSLayoutAttributeWidth)
- constraint.constant = r*16;
- }
- cell.imageWidthConstraint.constant = r*16;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement