collection官網(wǎng) 如何純代碼給UICollectionView添加HeaderView?
如何純代碼給UICollectionView添加HeaderView?從uicollectionreusableview繼承。例如,@interface headercrview:uicollecti
如何純代碼給UICollectionView添加HeaderView?
從uicollectionreusableview繼承。
例如,@interface headercrview:uicollectionreusableview
然后通過registerclass在VC中注冊該類
[自收集視圖registerClass:[HeaderCRView類]
對于SupplementaryViewOfKind:UICollectionElementKindSectionHeader
使用識別器:kheaderIdentifier
]當然,此設(shè)置應(yīng)該別忘了
-(cgsize)collectionview:(uicollectionview
*)collectionview layout:(uicollectionviewlayout*)collectionviewlayout
引用headerinsect的大?。海╪sinteger)section{
cgsize={320,45}
返回大小
uicollectionviewlayout通常是一個抽象類,抽象類只定義子類的一些公共屬性和行為,不能直接使用。Uicollectionviewflowlayout是流水線布局,這意味著UI控件將像流水線一樣,一行將滿,下一行將自動排列。當然,布局方法都是由apple編寫的,因此如果使用抽象類,則需要編寫自己的布局