Reputation: 408
I have cell with style UITableViewCellStyleSubtitle
. So if object is new i add image if not delete that image.
I try this:
if (something) {
UIImage *img = [UIImage imageNamed:@"new.png"];
cell.imageView.image = img;;
}
else
{
cell.imageView.image = nil;
}
But the title and subtitle mode to left. I want that there will be white space if not new.
I make this:
if (something) {
UIImage *img = [UIImage imageNamed:@"new.png"];
cell.imageView.image = img;;
}
else
{
cell.imageView.image = nil;
CGSize itemSize = CGSizeMake(25, 38);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
25 and 38 it width and height of my image.
It work fine, maybe it is more easy way to achieve this.
I want to achive this:
--
| | TextLabel
-- detailtext label
--
| | TextLabel
-- detailtext label
--
| | TextLabel
-- detailtext label
TextLabel
detailtext label
So cell will be straight. If not new no image but space. If new image.
Upvotes: 0
Views: 176
Reputation: 355
try
UIImage *img = [UIImage imageNamed:@"blankImage.png"];
on the place of
cell.imageView.image = nil;
where blankImage.png is simple white image.
Upvotes: 2