多图像UICollectionView单元格放置

时间:2019-04-05 19:16:12

标签: swift uicollectionview uicollectionviewlayout

enter image description here

在上面的图像中,我试图使尖端为#NOFILTER的单元格与个人资料图像单元格相邻并且在“ GO BOLD”尖端单元格的下方。

这是我当前设置的代码:

extension ProfileImagesSignupView: UICollectionViewDelegateFlowLayout{
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
    return UIEdgeInsets(top: conf.edgeInsetPadding, left: conf.edgeInsetPadding, bottom: conf.edgeInsetPadding, right: conf.edgeInsetPadding)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
    let itm = sections[indexPath.section].items[indexPath.item]
    switch itm{
    case .profile, .profileItem(_):
         var dimen: CGFloat = self.collectionView.frame.width - (2 * conf.edgeInsetPadding)
         let smallDimen = (dimen - (conf.itemsPerRow - 1) * conf.minimumInterItemSpacing) / conf.itemsPerRow

         dimen -= smallDimen
         dimen -= (conf.itemsPerRow - 2) * conf.minimumInterItemSpacing

         return CGSize(width: dimen, height: dimen)
    default:
        var dimen: CGFloat = self.collectionView.frame.width - (2 * conf.edgeInsetPadding)


        dimen = (dimen - (conf.itemsPerRow - 1) * conf.minimumInterItemSpacing) / conf.itemsPerRow
        //Small precision error causes issue, so a small subtraction in order to fix cell alignment
        dimen = dimen - CGFloat(0.05)
        return CGSize(width: dimen, height: dimen)
    }
}
}

任何人都知道这里要丢失什么以便将物品移走吗?

编辑:我目前在这里使用LXReorderableCollectionViewFlowLayout来支持拖放功能。

0 个答案:

没有答案