我创建了一个非常基本的UICollectionView与布局过渡位置:https://github.com/aubrey/TestCollectionView如何修复UICollectionViewFlowLayout不将样式应用于单元格?
这里有我的问题的视频:http://cl.ly/XHjZ
我的问题是我不知道在哪里/如何应用我添加到单元格的阴影。每当我添加它时,它都不会正确应用于转换后的单元格,并在转换回来后挂起。
在我didSelectItemAtIndexPath方法我试图在这里将阴影(无济于事):
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.collectionView.collectionViewLayout == self.smallLayout)
{
[self.largeLayout invalidateLayout];
[self.collectionView setCollectionViewLayout:self.largeLayout animated:YES];
[self.collectionView setPagingEnabled:YES];
}
else
{
[self.smallLayout invalidateLayout];
[self.collectionView setCollectionViewLayout:self.smallLayout animated:YES];
[self.collectionView setPagingEnabled:NO];
}
}
我还申请了影子在那里我建立我的自定义单元格:
@implementation MyCell
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.contentView.backgroundColor = [UIColor whiteColor];
self.myNumber = [UILabel new];
self.myNumber.text = @"Data Array Didn't Load";
self.myNumber.frame = CGRectMake(20, 20, 100, 100);
[self.contentView addSubview:self.myNumber];
// Shadow Setup
self.layer.masksToBounds = NO;
self.layer.shadowOpacity = 0.15f;
self.layer.shadowRadius = 1.4f;
self.layer.shadowOffset = CGSizeZero;
self.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
}
return self;
}