UICollectionView which behaves as a gallery
gallery.showsHorizontalScrollIndicator = false gallery.isPagingEnabled = true
is placed inside UIView container and on this container, custom button (favorite image button) is added:
galleryContainer.addSubview(gallery) galleryContainer.addSubview(pageControl) ... galleryContainer.addSubview(favBtn) favBtn.topAnchor.constraint(equalTo: galleryContainer.topAnchor, constant: 40).isActive = true favBtn.trailingAnchor.constraint(equalTo: galleryContainer.trailingAnchor, constant: -30).isActive = true favBtn.heightAnchor.constraint(equalToConstant: 30).isActive = true favBtn.widthAnchor.constraint(equalToConstant: 30).isActive = true
The problem is that the favorite button does not react on the tap, why, and how can this be fixed? I tried
favBtn.becomeFirstResponder() but without any success.