Skip to content

Instantly share code, notes, and snippets.

@mitulmanish
Created April 8, 2018 02:25
Show Gist options
  • Save mitulmanish/c36ee4696b948e9fb2f5c7d8e0cb6dc0 to your computer and use it in GitHub Desktop.
Save mitulmanish/c36ee4696b948e9fb2f5c7d8e0cb6dc0 to your computer and use it in GitHub Desktop.
class DashboardCollectionViewCell: UICollectionViewCell {
static var cellIdentifier: String {
return "dashboard-cell-identifier"
}
var imageView: CustomImageView = {
let imageView = CustomImageView()
imageView.clipsToBounds = true
imageView.contentMode = .scaleToFill
return imageView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupViews()
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupViews() {
contentView.addSubview(imageView)
imageView.pin(toView: contentView)
}
override func prepareForReuse() {
imageView.image = nil
imageView.downloadTask?.cancel()
}
func configure(withImageURLString urlString: String) {
imageView.loadImageUsing(urlString: urlString) { (_) in }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment