Created
October 27, 2013 16:38
-
-
Save piersadrian/7184689 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseID]; | |
if (! cell) { | |
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseID]; | |
cell = [self addLabelsToCell:cell]; | |
} | |
NSDictionary *client = [[clientTypes objectAtIndex:indexPath.section] objectAtIndex:indexPath.row]; | |
[(UILabel *)[cell viewWithTag:0] setText:[client objectForKey:@"client"]]; | |
[(UILabel *)[cell viewWithTag:1] setText:[NSString stringWithFormat:@"$%@", [client objectForKey:@"amount"]]]; | |
[cell.contentView layoutIfNeeded]; | |
return cell; | |
} | |
- (UITableViewCell *)addLabelsToCell:(UITableViewCell *)cell | |
{ | |
UILabel *name = [UILabel new]; | |
name.font = [UIFont systemFontOfSize:18]; | |
name.textColor = [UIColor blackColor]; | |
name.tag = 0; | |
[cell.contentView addSubview:name]; | |
UILabel *amount = [UILabel new]; | |
amount.font = [UIFont systemFontOfSize:12]; | |
amount.textColor = [UIColor grayColor]; | |
amount.tag = 1; | |
[cell.contentView addSubview:amount]; | |
[name alignCenterYWithView:cell.contentView predicate:nil]; | |
[name alignLeadingEdgeWithView:cell.contentView predicate:@"15"]; | |
[amount alignCenterYWithView:cell.contentView predicate:nil]; | |
[amount constrainLeadingSpaceToView:name predicate:@"20"]; | |
return cell; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment