当我实现以下代码时:
dynamic var predicate: NSPredicate? = {
return NSPredicate { object, _ in
(object as? MyClass)?.result
}
}()
通过使用sizeForItemAt方法,我可以绘制我想要的帧,但是我的自定义collectionview单元格无法更新,我错过了哪里,请帮助我!!
答案 0 :(得分:0)
i fix it by this ref UICollectionView cell subviews do not resize
thanks guys , at frist still have problem with my Cell.imageview , can not shape-round as i want , and i create a class for imageview ,below:
class CellImageView: UIImageView {
override func layoutSubviews() {
super.layoutSubviews()
let radius: CGFloat = self.bounds.size.width / 2.0
self.layer.cornerRadius = radius
self.clipsToBounds = true
}
and anything work perfectly
答案 1 :(得分:0)
在iOS 13中,对于我来说,我先将estimatedItemSize
固定为.zero
,然后将itemSize
设置为;
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.estimatedItemSize = .zero
layout.itemSize = CGSize(width: collectionView.frame.size.width, height: 80)
}