mirror of
https://github.com/danbee/persephone
synced 2025-03-04 08:39:11 +00:00
34 lines
1.2 KiB
Swift
34 lines
1.2 KiB
Swift
//
|
|
// AlbumViewController+UICollectionViewDelegateFlowLayout.swift
|
|
// Persephone
|
|
//
|
|
// Created by Daniel Barber on 2020-3-28.
|
|
// Copyright © 2020 Dan Barber. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
|
|
extension AlbumViewController: UICollectionViewDelegateFlowLayout {
|
|
func collectionView(_ collectionView: UICollectionView,
|
|
layout collectionViewLayout: UICollectionViewLayout,
|
|
sizeForItemAt indexPath: IndexPath) -> CGSize {
|
|
let paddingSpace = sectionInsets.left * (itemsPerRow + 1)
|
|
let availableWidth = view.frame.width - paddingSpace
|
|
let widthPerItem = availableWidth / itemsPerRow
|
|
|
|
return CGSize(width: widthPerItem, height: widthPerItem + 48)
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView,
|
|
layout collectionViewLayout: UICollectionViewLayout,
|
|
insetForSectionAt section: Int) -> UIEdgeInsets {
|
|
return sectionInsets
|
|
}
|
|
|
|
func collectionView(_ collectionView: UICollectionView,
|
|
layout collectionViewLayout: UICollectionViewLayout,
|
|
minimumLineSpacingForSectionAt section: Int) -> CGFloat {
|
|
return sectionInsets.left / 2
|
|
}
|
|
}
|