class NormalProjectCell: UICollectionViewCell, SelfConfiguringProjectCell { //MARK: - Properties let titleLabel = ProjectTitleLabel(withTextAlignment: .center, andFont: UIFont.preferredFont(forTextStyle: .title3), andColor: .label) let lastEditedLabel = ProjectTitleLabel(withTextAlignment: .center, andFont: UIFont.preferredFont(forTextStyle: .caption1), andColor: .secondaryLabel) let imageView = ProjectImageView(frame: .zero) var stackView = UIStackView() var backgroundMaskedView = UIView() //MARK: - Init override init(frame: CGRect) { super.init(frame: frame) self.layer.cornerRadius = 35 let seperator = Separator(frame: .zero) stackView = UIStackView(arrangedSubviews: [seperator, titleLabel, lastEditedLabel, imageView]) stackView.translatesAutoresizingMaskIntoConstraints = false stackView.axis = .vertical stackView.distribution = .fillProportionally stackView.spacing = 5 stackView.setCustomSpacing(10, after: lastEditedLabel) stackView.insertSubview(backgroundMaskedView, at: 0) contentView.addSubview(stackView) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } //MARK: - Layout override func layoutSubviews() { super.layoutSubviews() NSLayoutConstraint.activate([ titleLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 20), stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), stackView.topAnchor.constraint(equalTo: contentView.topAnchor), stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor) ]) backgroundMaskedView.translatesAutoresizingMaskIntoConstraints = false backgroundMaskedView.backgroundColor = .tertiarySystemBackground backgroundMaskedView.pinToEdges(of: stackView) let gradientMaskLayer = CAGradientLayer() gradientMaskLayer.frame = backgroundMaskedView.bounds gradientMaskLayer.colors = [UIColor.systemPurple.cgColor, UIColor.clear.cgColor] gradientMaskLayer.locations = [0, 0.4] backgroundMaskedView.layer.mask = gradientMaskLayer } //MARK: - Configure func configure(with project: ProjectsController.Project) { titleLabel.text = project.title lastEditedLabel.text = project.lastEdited.customMediumToString imageView.image = Bundle.getProjectImage(project: project) } }