{
......
myCollectCollectionView.contentInset = UIEdgeInsets(top: 120, left: 0, bottom: 0, right: 0)
let headerLable = UILabel(frame: CGRect(x: 0, y: -120, width: SCREEN_WIDTH, height: 120))
myCollectCollectionView.addSubview(headerLable)
headerLable.isUserInteractionEnabled = true
headerLable.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tap)))
headerLable.text = "My Header"
headerLable.textAlignment = .center
// head.backgroundColor = UIColor.red
}
@objc func tap(){
print("tap")
}
给UICollectionView添加头部视图headerView
网友评论