title: CollectionView is not showing inside a view in Swift
body: <p>I have a view with a collection view inside it. I am adding this view to another view but the collection view is not showing. What am I doing wrong here?</p>
  <p><strong>I have a view  which has a collection view</strong></p>
  <pre><code>class GiftFilterView: UIView {
      
      var giftImageIcon: [UIImage] = [#imageLiteral(resourceName: &quot;Gift Mic Icon&quot;), #imageLiteral(resourceName: &quot;Gift Smile Icon&quot;), #imageLiteral(resourceName: &quot;Gift Gif Icon&quot;), #imageLiteral(resourceName: &quot;Gift Camera Icon&quot;), #imageLiteral(resourceName: &quot;Gift Gift Icon&quot;), #imageLiteral(resourceName: &quot;Gift Three Dot Icon&quot;)]
  
      //MARK:- Properties
      weak var delegate: sendMessageToChatScreenDelegate?
      weak var giftIcondelegate: GiftIconCellActionDeleate?
      
      lazy var collectionView: UICollectionView = {
          let layout = UICollectionViewFlowLayout()
          let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
          cv.translatesAutoresizingMaskIntoConstraints = false
          cv.backgroundColor = .white
          cv.delegate = self
          cv.dataSource = self
          cv.isScrollEnabled = false
          return cv
      }()
       lazy var customInputView: CustomInputAccesoryView = {
          let customView = CustomInputAccesoryView()
          customView.delegate = self
          return customView
      }()
  
       //MARK:- Lifecycles
      override init(frame: CGRect) {
          super.init(frame: frame)
          addSubview(customInputView)
          customInputView.anchor(top: topAnchor, left: leftAnchor, right: rightAnchor, paddingTop: 5)
          addSubview(collectionView)
          collectionView.anchor(top: customInputView.bottomAnchor, left: leftAnchor, paddingTop: 10)
          collectionView.setDimensions(width: self.frame.size.width, height: 30)
          backgroundColor = .white
          self.collectionView.register(GiftFilterCollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier)
          
      }
      
      required init?(coder: NSCoder) {
          fatalError(&quot;init(coder:) has not been implemented&quot;)
      }
  }
  
  //MARK:- UICollectionViewDataSource, UICollectionViewDelegate
  extension GiftFilterView: UICollectionViewDataSource, UICollectionViewDelegate{
      func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int {
          return giftImageIcon.count
      }
  
      func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
          guard let cell = self.collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as? GiftFilterCollectionViewCell else {
              return UICollectionViewCell()
          }
          cell.imageIcon = giftImageIcon[indexPath.row]
          return cell
      }
  
      func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
          giftIcondelegate?.changeKeyboardheight()
      }
      
  }
  //MARK:- UICollectionViewDelegateFlowLayout
  extension GiftFilterView: UICollectionViewDelegateFlowLayout{
      func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -&gt; CGSize {
          return CGSize(width: frame.width / CGFloat(giftImageIcon.count), height: 40)
      }
      func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -&gt; CGFloat {
          return 10
      }
      
  }
  
  </code></pre>
  <p><strong>I am adding this view to another view</strong></p>
  <pre><code>
  class GiftAccessoryCollectionView: UIView {
    
  
      //MARK:- Properties
      weak var delegate: sendMessageToChatScreenDelegate?
      weak var giftIcondelegate: GiftIconCellActionDeleate?
      
      private lazy var filterView: GiftFilterView = {
          let giftView = GiftFilterView()
          giftView.translatesAutoresizingMaskIntoConstraints = false
          return giftView
      }()
      
      //MARK:- Lifecycles
      override init(frame: CGRect) {
          super.init(frame: frame)
         addSubview(filterView)
          filterView.anchor(top: topAnchor, left: leftAnchor, right: rightAnchor,height: 130)
          addSubview(collectionView)
          collectionView.anchor(top: filterView.bottomAnchor, left: leftAnchor, paddingTop: 10)
          collectionView.setDimensions(width: self.frame.size.width, height: 260)
  
      
      }
      
      required init?(coder: NSCoder) {
          fatalError(&quot;init(coder:) has not been implemented&quot;)
      }
  }
  
  </code></pre>
  <p>But the collection view is not showing when I am adding the view to another view.</p>