如何访问viewForSupplementaryElementOfKind中的section index?

时间:2016-06-10 14:21:55

标签: swift uicollectionview

对于我的UICollectionView,我做了一个像这样的标题:

override func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {

let view = collectionView.dequeueReusableSupplementaryViewOfKind(kind, withReuseIdentifier: "B3header", forIndexPath: indexPath)

view.backgroundColor = UIColor(patternImage: UIImage(named: headerImage)!)

return view

}

现在问题是,我想更改有关节号的headerImage,类似于:

view.backgroundColor = UIColor(patternImage: UIImage(named: "headerImage\(section)")!)

我能够使用numberOfItemsInSection访问该索引,我想知道如何访问该值以动态更改标题的背景。

或许还有另一种方式?

谢谢!

0 个答案:

没有答案
相关问题