Q:

How change size of imageView(SubView) in Cell in CollectionView

I have a problem with image in cell.  More precisely image in assets are bigger than cell.  How i can transform image to smaller size?  
`   var photos = ["IMG_3814","IMG_3803"]
override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view. 
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return photos.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cellID", for: indexPath)
    let img = photos[indexPath.row]
    let imageView: UIImageView = UIImageView(image: UIImage(named: img))

    cell.contentView.addSubview(imageView)

    return cell
}`

A:

Try using 
let imageView: UIImageView = UIImageView(image: UIImage(named: img))
imageView.frame = cell.contentView.frame
imageView.contentMode = .scaleAspectFit

it will adjust your image to imageView

