【问题标题】:Change the collection view cell size更改集合视图单元格大小
【发布时间】:2017-01-25 07:31:02
【问题描述】:

我想调整FSCalendar 的日期框大小,它位于collectionView 单元格内。

请帮我更改FSCalendar 中的集合视图单元格大小。

【问题讨论】:

    标签: ios objective-c swift3 uicollectionviewcell


    【解决方案1】:

    添加 UICollectionViewDelegateFlowLayout 后使用此功能:

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
             return CGSize(width: screenWidth, height: screenWidth)
        }
    

    【讨论】:

      【解决方案2】:

      你可以使用 UICollectionView 的委托方法来改变 CollectionView 的高度和宽度

      在斯威夫特中

      public func collectionView(_ collectionView: UICollectionView, transitionLayoutForOldLayout fromLayout: UICollectionViewLayout, newLayout toLayout: UICollectionViewLayout) -> UICollectionViewTransitionLayout
      
      
      func setCollectionViewLayout(_ layout: UICollectionViewLayout, animated: Bool)
      

      【讨论】: