如何在UICollectionView Swift3中自定义标题

如何在UICollectionView Swift3中自定义标题,swift3,Swift3,我试图利用UICollectionView中的标题,我希望标题本身也是一个collectionview 在我的班上 class headerView : UICollectionResuableView { override init(frame: frame) setupViews() required init?(coder: aDecoder: NSCoder){ super.init(coder: aDecoder) } let headerCollectionView = UICol

我试图利用UICollectionView中的标题,我希望标题本身也是一个collectionview

在我的班上

class headerView : UICollectionResuableView {
override init(frame: frame)
setupViews()

required init?(coder: aDecoder: NSCoder){
super.init(coder: aDecoder)
}
let headerCollectionView = UICollectionView = {
let layout =UICollectionViewFlowLayout()
let collectionView = UICollectionView(frame: .zero, collectionViewLayout: layout)
collectionView.translatesAutoresizingMaskIntoConstrains = false
collectionView.backgroundColor =UIColor.white
return collectionView
}()

func setupViews(){
backgroundColor = UIColor.blue
addSubview(headerCollectionView)
addConstrains(...)//horizontal
addConstrains(...)//vertical


}


}
我已经把上面的代码写下来了,运行之后,我发现没有任何变化。我改变了背景颜色,它仍然是一样的

我的标题中也有一个标签。这只是一个简单的出口,有一些文字,标签上仍然显示着文字内容

我的意图是在我的标题中标签的正下方有另一个collectionview

我还尝试在collectionview控制器中注册我的headerView类,但出现了一个编译错误,表示寄存器不会使用我提供的参数调用

请告诉我如何获得一个美丽的工作collectionview标题,使collectionview


谢谢你,新年快乐

您的代码不符合要求,请修复它,我们可以看一看。您的意思是什么不符合要求?我给你的部分只是为了标题你的代码不符合,请修复它,我们可以看一看。你什么意思是不符合?我给的那部分只是头球