iOS-Swift-The 集合视图的位置 header
iOS-Swift-The location of collectionView header
我想在 collectionView 中添加 header,但我不知道如何删除导航栏和单元格之间的空白 space。有人给我一些建议吗?谢谢
下面是ViewController
class CelebrityVC: UIViewController, ButtonDelegate, UICollectionViewDataSource, UICollectionViewDelegate {
var collectionView:UICollectionView!
let reuseIdentifier_header = "CelebrityHeader"
let reuseIdentifier = "listviewcell"
override func viewDidLoad() {
super.viewDidLoad()
MakeBarButton(self)
let screenWidth = getScreenWidth()
let screenHeight = getScreenHeight()
let flowLayout = CSStickyHeaderFlowLayout()
collectionView = UICollectionView(frame: CGRectMake(0, self.navigationController!.navigationBar.frame.size.height+statusBarHeight() ,screenWidth, screenHeight-(self.navigationController!.navigationBar.frame.size.height+statusBarHeight())), collectionViewLayout: flowLayout)
collectionView.backgroundColor=UIColor.whiteColor()
collectionView.delegate=self
collectionView.dataSource=self
self.view!.addSubview(collectionView)
let nib = UINib(nibName: "ListViewCell", bundle: nil)
collectionView.registerNib(nib, forCellWithReuseIdentifier: reuseIdentifier)
let nib_header = UINib(nibName: "CelebrityHeader", bundle: nil)
collectionView.registerNib(nib_header, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: reuseIdentifier_header)
self.collectionView?.registerClass(CelebrityHeader.self, forSupplementaryViewOfKind: CSStickyHeaderParallaxHeader, withReuseIdentifier: reuseIdentifier_header)
只需在你的ViewDidLoad
方法中添加这个
self.automaticallyAdjustsScrollViewInsets = NO;
我想在 collectionView 中添加 header,但我不知道如何删除导航栏和单元格之间的空白 space。有人给我一些建议吗?谢谢
下面是ViewController
class CelebrityVC: UIViewController, ButtonDelegate, UICollectionViewDataSource, UICollectionViewDelegate {
var collectionView:UICollectionView!
let reuseIdentifier_header = "CelebrityHeader"
let reuseIdentifier = "listviewcell"
override func viewDidLoad() {
super.viewDidLoad()
MakeBarButton(self)
let screenWidth = getScreenWidth()
let screenHeight = getScreenHeight()
let flowLayout = CSStickyHeaderFlowLayout()
collectionView = UICollectionView(frame: CGRectMake(0, self.navigationController!.navigationBar.frame.size.height+statusBarHeight() ,screenWidth, screenHeight-(self.navigationController!.navigationBar.frame.size.height+statusBarHeight())), collectionViewLayout: flowLayout)
collectionView.backgroundColor=UIColor.whiteColor()
collectionView.delegate=self
collectionView.dataSource=self
self.view!.addSubview(collectionView)
let nib = UINib(nibName: "ListViewCell", bundle: nil)
collectionView.registerNib(nib, forCellWithReuseIdentifier: reuseIdentifier)
let nib_header = UINib(nibName: "CelebrityHeader", bundle: nil)
collectionView.registerNib(nib_header, forSupplementaryViewOfKind: UICollectionElementKindSectionHeader, withReuseIdentifier: reuseIdentifier_header)
self.collectionView?.registerClass(CelebrityHeader.self, forSupplementaryViewOfKind: CSStickyHeaderParallaxHeader, withReuseIdentifier: reuseIdentifier_header)
只需在你的ViewDidLoad
方法中添加这个
self.automaticallyAdjustsScrollViewInsets = NO;