I am trying to enter MPMediaItemArtwork
Image into UITableView's
cell's ImageView with following code.
MPMediaItemArtwork *artwork = [[[self.arrayOfAlbums objectAtIndex:indexPath.row] representativeItem]valueForProperty:MPMediaItemPropertyArtwork];
UIImage *artworkImage = [artwork imageWithSize: cell.imageView.bounds.size];
if (artworkImage)
{
cell.imageView.image = artworkImage;
}
else
{
cell.imageView.image = [UIImage imageNamed: @"noArtwork.png"];
}
It's okay when i insert Artwork image in UITableView's
cell ImageView
.
But when my artwork image is too small or big , it's happened like following pic. Not in completely fill in cell's ImageView.
You see that? I want to set Fill with Stretch
like iOS Music App
Here is Build-in App Artwork Image that set Completely fill with Stretch
I want to do like that.
So i used cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
however it's not effect.
So how can i do that? Thanks you for your work.
Try this for calculating a new and fitting image; Adjust
newRect
to the rect of your cell.