I have a tableView with a cell created in cellForRowAtIndexPath and add some dummy text:
cell = UITableViewCell(style: UITableViewCellStyle.Subtitle,
reuseIdentifier: "cell")
cell.textLabel?.text = "Test Title"
cell.detailTextLabel?.text = "Test detail label"
Then I add a test image to the cell's imageView:
var image = UIImage(named: "cd.png")
cell.imageView!.image = image
Result:
To adjust the color, I use the following code:
cell.imageView?.tintColor = UIColor.redColor()
Result:
The image is too big in the cell, so I adjust the size using the following code:
var itemSize:CGSize = CGSizeMake(20, 20)
UIGraphicsBeginImageContextWithOptions(itemSize, false, UIScreen.mainScreen().scale)
var imageRect : CGRect = CGRectMake(0, 0, itemSize.width, itemSize.height)
cell.imageView!.image?.drawInRect(imageRect)
cell.imageView!.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
Whilst the image does resize, the tintColor is lost:
Any ideas please?