//设置内偏移
self.collectionView.contentInset = UIEdgeInsetsMake(200, 0, 0, 0);
// headerView try 从-200开始
UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, -200, self.view.frame.size.width, 200)];
//UICollectionView如果在数据不够一屏时上下滚动
当数据不多,collectionView.contentSize小于collectionView.frame.size的时候,UICollectionView是不会滚动的
self.Cov.alwaysBounceVertical = YES;
就可以了
//几个属性的理解
contentInset:给view额外追加的内容(内边距)
//假设一个scrollerview
UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
scroller.contentSize = CGSizeMake(100, 100);
scroller.contentInset = UIEdgeInsetsMake(100, 100, 100, 100);//(追加上左下右各100)
此时 scroller.contentSize 还是100 100
但是 scroller.contentOffset 从min(0,0)max(100,100)变成了 min(-100,-100)max(200,200)
scroller.contentOffset的(0,0)点依旧是(0,0)没变。
//UIEdgeInsetscontentInset (外边距)
关于contentInset和UIEdgeInsetscontentInset的链接