CollctionView添加头部视图,不是sectionHeader

来源:互联网 发布:盲打高手打飞字 源码 编辑:程序博客网 时间:2024/06/05 19:48
self.collectionView  =  [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height) collectionViewLayout:flowlayout];self.collectionView.contentInset = UIEdgeInsetsMake(50, 0, 0, 0);UIImageView *imagev = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"015.png"]];imagev.frame = CGRectMake(0, -50, 320, 50);[self.collectionView addSubview: imagev];[self.view addSubview: _collectionView];

I use the attribute contentInset to insert a frame to the top of the UICollectionView, then I add the image view to it, and it succeeds. I think it can act excactly as UITableView's tableHeaderView property. What do you think?

0 0
原创粉丝点击