UICollectionViewCell
class ImageCollectionCell: UICollectionViewCell {
var iv: UIImageView!
override init(frame:CGRect) {
super.init(frame: frame)
setupSubview()
}
required init?(coder aDecoder:NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setupSubview() {
let imageView = UIImageView()
contentView.addSubview(imageView)
imageView.contentMode = .scaleAspectFit
iv = imageView
}
func setContentImage(_im:UIImage?) {
iv.image = im
setNeedsLayout()
}
override fun clayoutSubviews() {
let width = UIScreen.main.bounds.width/2
iv.frame = CGRect(x:0, y:0, width: width, height: width)
}
}
UITableViewCell

网友评论