Viken Ong
Viken Ong

Reputation: 109

Aligning images of different sizes

I have a different size of image to be input as a thumbnail of a tableview, is there a way to make all the image align despite their different in size? since in my case, the location of the text will follow the image, so it won't be neat. Here's the code that I use to input the image

static NSString *CellIdentifier = @"Cell"; 
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell.textLabel.text = title;
cell.textLabel.adjustsFontSizeToFitWidth = YES;
cell.imageView.image = thumb;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;

Upvotes: 2

Views: 378

Answers (2)

Vilém Kurz
Vilém Kurz

Reputation: 3410

Cell.imageView is a UIImageView, which is a subclass of UIView. Look at documentation of UIView - exactly "Configuring the Resizing Behavior". Maybe something of that helps.

But beware - resizing on the fly can reduce scrolling behaviour of the tableview. Maybe better way is to resize images to fit the size of the uiimageview before actually using them in tableview.

Upvotes: 1

Deepak Danduprolu
Deepak Danduprolu

Reputation: 44633

You can always set the frame of the imageView and textLabel objects as you want them to be.

Upvotes: 1

Related Questions