美文网首页
给UICollectionView添加头部headerView

给UICollectionView添加头部headerView

作者: 不要虚度美好的时光 | 来源:发表于2022-04-29 16:03 被阅读0次
    {
    ......
            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

    相关文章

      网友评论

          本文标题:给UICollectionView添加头部headerView

          本文链接:https://www.haomeiwen.com/subject/eyeyyrtx.html