0
votes

I am setting the background image for UITableViewCell it is working fine but it stretches the image i do not want to stretch the image and i want the image should be of same size in cell so i think cell size should be same

here is the code for cell image

cell.backgroundView = [[[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"1.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0]]autorelease];  

My image size is "275 (width) * 59 (height)".

Any idea how to fix this issue.

2

2 Answers

0
votes

Try this

UIImageView *imgV = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"1.png"];
imgV.contentMode = UIViewContentModeScaleAspectFit;
cell.backgroundView = imgV;

AspectFit and some more modes are there. I am not sure whether it will work for cell back groundView. Just give a try.

0
votes

Make a custom cell of UITableView and set the frame of UIImageView exactly to the dimension of the image that is in your case width is 275 and height is 59 so set the frame of UIImageView according to your image height and width image will not stretch.