UICollectionview背景是黑色无法修改
如图所示, 我在一个viewcontroller.view里面添加了一个collectionView和一个tableview, collectionview的背景色为黑色, 修改过background color却不管用是什么原因呢?
一些相关代码片段:
一、viewcontroller添加collection
MagicsPhotoWaterFallLayout *layout = [[MagicsPhotoWaterFallLayout alloc] init];
layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
self.waterFallLayoutView = [[MaigcsPhotoWaterFallViewController alloc] initWithCollectionViewLayout:layout];
_waterFallLayoutView.tagId = self.tagId;
_waterFallLayoutView.viewFrame = CGRectMake(0, topBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT - topBarHeight);
[self.view addSubview:_waterFallLayoutView.view];
二、
在collectionview的viewdidload里面修改了背景色
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationController.navigationBar.translucent = NO;
self.view.backgroundColor = [UIColor whiteColor];
self.view.clipsToBounds = YES;
self.view.frame = self.viewFrame;
self.dataArray = [[NSMutableArray alloc] init];
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refreshControlValueChanged) forControlEvents:UIControlEventValueChanged];
MagicsPhotoWaterFallLayout *layout = (MagicsPhotoWaterFallLayout *)self.collectionView.collectionViewLayout;
layout.delegate = self;
self.itemWidth = layout.itemWidth;
[self.collectionView registerClass:[MagicsWaterFallViewCell class] forCellWithReuseIdentifier:waterFallCellIdentifier];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.collectionView setFooterHidden:NO];
__weak typeof(self) weakSelf = self;
[self.collectionView addFooterWithCallback:^{
[weakSelf dragResfreshAtTop:NO];
}];
[self dragResfreshAtTop:YES];
}
Soul残舞
10 years ago