我需要的是这样的:NSCollectionView与页眉和页脚
但我的代码做到这一点:
func collectionView(collectionView: NSCollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> NSView {
let a = myView()
if kind == NSCollectionElementKindSectionHeader {
a.frame = NSMakeRect(0, 0, 1000, 10)
}
else if kind == NSCollectionElementKindSectionFooter {
a.frame = NSMakeRect(0, 0, 1000, 12)
}
return a
}
func numberOfSectionsInCollectionView(collectionView: NSCollectionView) -> Int {
return 3
}
override func numberOfItemsInSection(section: Int) -> Int {
if section == 0 {
return 5
}
else if section == 1 {
return 5
}
return 10
}
两个页眉和页脚中的位置x = 0,y = 0,所以如何计算我的自定义视图中的y位置(Header和页脚)?
你所需的水平滚动或固定宽度? –
@ArunAmmannaya固定宽度 – Geek20
然后使用UITableview可以轻松实现。 UITableview非常适合这种需求。 –