页眉和页脚不会出现(Swift)

时间:2016-06-10 18:41:45

标签: ios swift header uicollectionview footer

~Swift的新手〜

下面是我必须在我的UICollectionView中实现页眉和页脚视图的函数,但截至目前,当我运行我的应用程序时,没有任何东西出现。

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
    switch  kind {
    case UICollectionElementKindSectionHeader:
      let headerView = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "Header", forIndexPath: indexPath) 
      headerView.backgroundColor = UIColor.brownColor()
      return headerView
    case UICollectionElementKindSectionFooter:
      let footerView = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "Footer", forIndexPath: indexPath)
      footerView.backgroundColor = UIColor.darkGrayColor()
      return footerView
    default:
      assert(false, "Unexpected element kind")
    }
 }

0 个答案:

没有答案