我創建了一個非常基本的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;
}