zoukankan      html  css  js  c++  java
  • UICollectionview的头视图和尾视图

    UITableView有头视图和尾视图,那么UICollectionView有没有头视图和尾视图呢?

    答案是有的.

    1.新建一个类,必须继承自 UICollectionReusableView.

    2.需要实现UIcollectionViewDataSource中的方法:viewForSupplementaryElementOfKind;

     1 - (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath{
     2 
     3     UICollectionReusableView *reusableView = nil;
     4 
     5     if ([kind isEqualToString:UICollectionElementKindSectionHeader]) {
     6 
     7         HLTopicItemHeader * header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:kTopicHeaderIdentifier forIndexPath:indexPath];
     8 
     9         //有缓存了
    10         [header.imgV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",kDataServer2,_topic_img_url]] placeholderImage:[UIImage imageNamed:@"AppIcon60x60@3x"]];
    11 
    12         header.title.text = _topic_title;
    13         reusableView = header;
    14     }
    15 
    16     return reusableView;
    17 }

    今天才知道UICollectionView原来还有头视图和尾视图呀...嘿嘿!!!

  • 相关阅读:
    十一周总结
    第十周课程总结
    第九周课程总结&实验报告
    第八周课程总结&实验报告
    第七周&实验报告五
    第六周&Java实验报告四
    课程总结
    第十四周课程总结
    第十三周总结
    十二周课程总结
  • 原文地址:https://www.cnblogs.com/pengsi/p/5336593.html
Copyright © 2011-2022 走看看