Cell 展開收合效果
tableView.estimatedRowHeight = 60 tableView.rowHeight = UITableView.automaticDimension
let flowLayout = collectionView.collectionViewLayout as! UICollectionViewFlowLayout flowLayout.estimatedItemSize = CGSize(width: UIScreen.main.bounds.width - 20, height: 200)override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) -> UICollectionViewLayoutAttributes { setNeedsLayout() layoutIfNeeded() let size = contentView.systemLayoutSizeFitting(layoutAttributes.size) var frame = layoutAttributes.frame frame.size.height = ceil(size.height) layoutAttributes.frame = frame return layoutAttributes }
Last updated