Created
February 15, 2018 09:51
-
-
Save Kun-Yao-Lin/b882cfc9859d647108a75cfde2be31d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark Collection Layout Delegate | |
-(CGSize)collectionView:(UICollectionView *)collectionView | |
layout:(UICollectionViewLayout *)collectionViewLayout | |
sizeForItemAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
NSUInteger item = indexPath.item; | |
if (item < [self.pageResult.results count] && indexPath.section == 0) { | |
//------------ 重點 ------------ | |
NewsInfoCollectionViewCell *cell = (NewsInfoCollectionViewCell *) [collectionView cellForItemAtIndexPath:indexPath]; | |
if (cell == nil) { | |
NSString *collectionViewCellClassName = NSStringFromClass(NewsInfoCollectionViewCell.class); | |
cell = [[[NSBundle mainBundle] loadNibNamed:collectionViewCellClassName | |
owner:nil | |
options:nil] firstObject]; | |
} | |
[self renderCell:cell item:item]; | |
cell.contentView.bounds = CGRectMake(0, 0, self.screenWidth, 10); | |
CGSize size = [cell systemLayoutSizeFittingSize:UILayoutFittingCompressedSize | |
withHorizontalFittingPriority:UILayoutPriorityDefaultHigh | |
verticalFittingPriority:UILayoutPriorityDefaultLow]; | |
return size; | |
//------------ 重點結束 ------------ | |
} | |
return [super collectionView:collectionView layout:collectionViewLayout sizeForItemAtIndexPath:indexPath]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment