Created
August 17, 2017 23:01
-
-
Save efremidze/a617b0af36c37b79f98effa945a0bedb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cell: UICollectionViewCell { | |
@IBOutlet weak var imageView: UIImageView! | |
private static var sharedInstance: Cell! | |
static func makeCell(width: CGFloat) -> Cell { | |
if sharedInstance == nil { | |
sharedInstance = UINib(nibName: String(describing: Cell.self)).instantiate(withOwner: nil, options: nil).first as! Cell | |
sharedInstance.constrain { [$0.imageView.widthAnchor.constraint(equalToConstant: width)] } | |
} | |
return sharedInstance | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment