因为我在视图中锚定了视图,所以我不知道如何继续。有什么功能我应该打电话?我使用自己的锚定功能btw
view.addSubview(projectHashtagInputView)
selectImageView.addSubview(collectionView)
collectionView.anchor(top: selectImageView.chooseImagesButton.bottomAnchor, left: selectImageView.leftAnchor, bottom: nil, right: selectImageView.rightAnchor, paddingTop: 2, paddingLeft: 2, paddingBottom: 2, paddingRight: 2, width: 0, height: 75)
selectImageView.anchor(top: projectHashtagInputView.bottomAnchor, left: view.safeAreaLayoutGuide.leftAnchor, bottom: collectionView.bottomAnchor, right: view.rightAnchor, paddingTop: 4, paddingLeft: 12, paddingBottom: -10, paddingRight: rightPadding, width: 0, height: 0)
如何显示整个collectionView?
答案 0 :(得分:0)
覆盖UICollectionView
并像这样实现
class CollectionView: UICollectionView {
override var contentSize: CGSize {
didSet {
invalidateIntrinsicContentSize()
}
}
override var intrinsicContentSize: CGSize {
return CGSize(width: max(10, contentSize.width), height: max(10, height)
}
}
将该类设置为集合视图的类。现在,如果您不添加高度限制,集合视图将展开以显示其所有内容。