// // GiphyCollectionViewCell.swift // LiveLikeGiphyChallenge // // Created by Arbnor Tefiki on 6.2.22. // import UIKit class GiphyCollectionViewCell: UICollectionViewCell { fileprivate let imageView: CachedImageView = { let imageView = CachedImageView() imageView.contentMode = .scaleAspectFill imageView.clipsToBounds = true imageView.translatesAutoresizingMaskIntoConstraints = false return imageView }() override init(frame: CGRect) { super.init(frame: frame) commonInit() } required init?(coder: NSCoder) { super.init(coder: coder) commonInit() } private func commonInit() { contentView.addSubview(imageView) setupConstraints() } func setupConstraints() { NSLayoutConstraint.activate([ imageView.topAnchor.constraint(equalTo: contentView.topAnchor), imageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), imageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), imageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor) ]) } func setupCell(url: String) { self.imageView.loadAsyncImage(url: url, placeholder: UIImage(named: "default_image")) } }