I Created a grouped table view, an开发者_Python百科d I noticed that placing an image in the imageView results in an image that is too large. It overlaps the rounded borders of the cell, which is horrible. I tried looking for a way to resize it, but I found many answers that didn't quite satisfy me. How would you do this? Which is the simplest way to go? The solutions I found where strangely complicated. Thanks!
The other solutions didn't satisfy me. The only good solution I found is this. You can resize the UIImage which is passed to the UIImageView.
The easy way is doing in Interface Builder. Select your UIImegeView
and go to the Inspector 1 view, yo can see View/Mode here choose ScaleAspectFit
or ScaleToFill
.
Else do it by code:
imageView.contentMode = UIViewContentModeScaleAspectFit;
or
imageView.contentMode = UIViewContentModeScaleToFill;
Sorry I made a mistake. First add you image to the tableview cell:
cell.imageView.image = [UIImage imageNamed:@"image.png"];
then set the content mode:
cell.imageView.contentMode = UIViewContentModeScaleAspectFit;
or
cell.imageView.contentMode = UIViewContentModeScaleToFill;
精彩评论