Hi, I have a table view and I can successfully add a an image to the left side of it using the 'cell.imageView.image = newImage;'.
What I am trying to do is add a UILabel ontop of this image. The tableView holds clients and in the clients there are X number of jobs for that client. If there are 3 jobs that are currently happening for that client I would like the integer 3 appear over the image in the tableView.
I have been at it for a few hours now with no luck. I think my solution is to add them together first and then add that as a UIImage, but I am not getting it? any ideas?
Psudo code
Make UILabel
Make UIImage
Add UILabel to UIImage
Add UIImage to UITableView cell.
Return cell
What I am trying to do is add a UILabel ontop of this image. The tableView holds clients and in the clients there are X number of jobs for that client. If there are 3 jobs that are currently happening for that client I would like the integer 3 appear over the image in the tableView.
I have been at it for a few hours now with no luck. I think my solution is to add them together first and then add that as a UIImage, but I am not getting it? any ideas?
Psudo code
Make UILabel
Make UIImage
Add UILabel to UIImage
Add UIImage to UITableView cell.
Return cell
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
NSDictionary *tempDict = [[NSDictionary alloc] initWithDictionary:[clientListForTable objectAtIndex:indexPath.row]];
cell.textLabel.text = [tempDict objectForKey:@"client"];
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:18.0];
cell.textLabel.font = [UIFont boldSystemFontOfSize:16.0];
cell.textLabel.textColor = [UIColor whiteColor];
cell.detailTextLabel.text = [tempDict objectForKey:@"businessName"];
cell.detailTextLabel.textColor = [UIColor whiteColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
CGRect boxRect = CGRectMake(0, 0, 44, 44);
UIImage *newImage = [UIImage imageNamed:@"greenSquare.png"];
UILabel *numLabel = [[UILabel alloc] initWithFrame:boxRect];
numLabel.text = @"3";
numLabel.textColor = [UIColor blackColor];
numLabel.backgroundColor = [UIColor clearColor];
//How to add the UILabel to the UIImage
cell.imageView.image = newImage;
return cell;
}