-1

I am downloading images from server using SDWebImage Library and place in UITableViewCell but all images Loaded in imageView correctly but last two images loaded larger than imageview size. i put imageView in A View and set aspect ratio of Parent view in which imageView is placed. i tried all content mode of imageview but not know what the problem is.but when i set aspect ratio on imageView then that particular two last images not loaded in UITableViewCell.

Normal Images In UITableViewCell

enter image description here

and last two images got the imageView Bigger

enter image description here

but when i set aspect ratio to aspect fit on imageview in storyboard then those last two images not loaded in imageView

any suggestion

a.masri
  • 2,439
  • 1
  • 14
  • 32
Majid
  • 41
  • 9
  • Difficult to say without knowing how you are setting the frame of the `UIImageView`. Is it done via autolayout. If it's the control itself that is getting larger something is wrong with setting it's frame and until that is correct the aspect ratio setting won't help. – Upholder Of Truth Jun 13 '18 at 11:38

1 Answers1

0

To have the image only show within the view that it's in (the UIImageView), you'll want to use this:

self.imageView.clipsToBounds = true

If you want it to keep it's aspect ratio within the UIImageView, you'll want to use this:

self.imageView.contentMode = .scaleAspectFill

If this is still too large, try experimenting with:

.scaleAspectFit
.scaleToFill
Daniel Dramond
  • 1,538
  • 2
  • 15
  • 26