美文网首页
为UICollectionView添加headView

为UICollectionView添加headView

作者: 张无奈 | 来源:发表于2021-05-07 16:44 被阅读0次

    - (void)viewDidLoad {

        [super viewDidLoad];

         [self contentInsetHeaderView];

    }

    - (void)contentInsetHeaderView {

        CGFloatheader_y =120;

        self.coll.contentInset = UIEdgeInsetsMake(120, 0, 0, 0);

        self.photo.frame = CGRectMake(0, -header_y,WIDTH, header_y);

        [self.coll addSubview:self.photo];

        [self.coll setContentOffset:CGPointMake(0, -header_y)];

    }

    #pragma mark- LazyLoad

    - (UICollectionView *)coll{

        if(!_coll) {

            UICollectionViewFlowLayout *Layout = [[UICollectionViewFlowLayout alloc] init];

            Layout.minimumLineSpacing = Layout.minimumInteritemSpacing = 12;

            _coll = [[UICollectionView alloc] initWithFrame:CGRectMake(12, 0, WIDTH - 24, MyViewHEIGHT) collectionViewLayout:Layout];

            _coll.backgroundColor = [UIColor whiteColor];

            [_coll MaskToBounds:8];

            _coll.alwaysBounceVertical = YES;

            _coll.showsHorizontalScrollIndicator = NO;

            _coll.showsVerticalScrollIndicator = NO;

            [_coll registerClass:[MedicalRecordsManaCell class] forCellWithReuseIdentifier:@"MedicalRecordsManaCell"];

            _coll.dataSource=self;

            _coll.delegate=self;

        }return_coll;

    }

    相关文章

      网友评论

          本文标题:为UICollectionView添加headView

          本文链接:https://www.haomeiwen.com/subject/imqedltx.html