创建带Xib的UICollectionViewController步骤
1、默认创建的Xib中的视图是UIView,将其删除;
2、拖拽一个UICollectionView视图到Xib,连线到File'Owner;
3、自定义Cell,注册Cell;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
[self.collectionView registerNib:[UINib nibWithNibName:@"MyCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"cell"];
}
4、实现delegateDataSource三个方法
5、设置背景色,默认为黑色
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setNaviTiTleByLabel];
self.collectionView.backgroundColor = [UIColor whiteColor];
}