nunzio giulio caggegi nunzio giulio caggegi - 1 year ago 113
Swift Question

Swift To Group Images

I should create what you see in the image. I have an array of images and I should group them. When I click should open a window with all the images. does anyone have any idea?enter image description here

Answer Source

Well since you have no idea I will give a short one. You need a collectionView and 2 different collectionViewCells.

  1. First Collection Cell (containing a UIImageView) which will be used to show the image
  2. Second Collection Cell will have a UIImageView, above it a transparent UIView with black color, and above both there should be a an UILabel in the middle showing the number of photos that you've not shown.

UIViewController should conform to UICollectionViewDelegate where you need to handle this thing

func collectionView(_ collectionView: UICollectionView,
                    didSelectItemAt indexPath: IndexPath) {
    // This is the last element where you show the second custom cell
    if indexPath.item == collectionView.numberOfItems(inSection: indexPath.section) - 1 {
        // Load all the items and pass it to the controller that you need to present

Now good luck at implementing it as it helps you to get better at understanding how things work on iOS

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download