Skip to content

Instantly share code, notes, and snippets.

@stevencurtis
Created July 3, 2020 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevencurtis/9d30d10f148d8ac20452367c6738dcfd to your computer and use it in GitHub Desktop.
Save stevencurtis/9d30d10f148d8ac20452367c6738dcfd to your computer and use it in GitHub Desktop.
appstandardcollectionviewcell
class AppStandardCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var getButton: UIButton!
@IBOutlet weak var subtitle: UILabel!
@IBOutlet weak var title: UILabel!
@IBOutlet weak var inAppLabel: UILabel!
@IBOutlet weak var appImage: UIImageView!
@IBOutlet weak var border: UIView!
var subscribeButtonAction: (() -> ())?
public func configure(with data: AppDataModel, final: Bool) {
title.text = data.title
subtitle.text = data.subtitle
inAppLabel.isHidden = !((data.inApp) ?? false)
(final) ? (border.isHidden = true) : (border.isHidden = false)
appImage.image = UIImage(named: data.smallImage)
}
override func awakeFromNib() {
super.awakeFromNib()
getButton.layer.cornerRadius = 15
appImage.layer.cornerRadius = 12
self.getButton.addTarget(self, action: #selector(getButtonTapped(_:)), for: .touchUpInside)
}
@IBAction func getButtonTapped(_ sender: UIButton){
subscribeButtonAction?()
}
// Gives the cell a chance to modify the attributes provided by the layout object.
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes)
-> UICollectionViewLayoutAttributes {
return layoutAttributes
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment