func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: headerViewCellID, for: indexPath) as UICollectionReusableView
var nameLabel = headerView.viewWithTag(9999)
if let nameLabel = nameLabel {
var nameLab = nameLabel as! UILabel
nameLab.text = sectionArray[indexPath.section]
} else {
var secondLabel : UILabel = UILabel.init(frame: CGRectMake(16, 24, 100, 18))
secondLabel.tag = 9999
secondLabel.textAlignment = .left
headerView.addSubview(secondLabel)
secondLabel.text = sectionArray[indexPath.section]
}
return headerView
}
网友评论