--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 他是苹果官方提供的一种瀑布流效果
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
// 不同于tableView,它用item进行显示,所有需要先设置每个item有大
flowLayout.itemSize = CGSizeMake(75, 110);
UICollectionView *collectView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:flowLayout];
// 和tableView很像
// 行间距
flowLayout.minimumLineSpacing = 10;
// 列间距
flowLayout.minimumInteritemSpacing = 10;
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 通过注册的方式创建cell
// 注册对象类型,重用标志
[collectView registerClass:[MyCell class] forCellWithReuseIdentifier:@"reuse"];
collectView.contentInset = UIEdgeInsetsMake(0, 20, 0, 20);
[self createData];
flowLayout.headerReferenceSize = CGSizeMake(0, 300);
// flowLayout.footerReferenceSize = CGSizeMake(0, 300);
[collectView registerClass:[MyCollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"headerView"];
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// 单例
#import "User.h"
@implementation User
+(User *)shareUSer{
static User *user;
static dispatch_once_t oneToken;
dispatch_once(&oneToken, ^{
user = [[User alloc] init];
});
return user;
}
@end
----------------------------------------------------------------------------