[英]Collection View Dynamic Cell size in ios
如何通過收藏夾視圖實現此目的? 我已經嘗試過sizeForItemAtIndexPath,但是沒有按我的意願工作?
誰能建議我該怎么做?
編輯:我已經完成:
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.item==0)
{
return CGSizeMake(200,200);
}
else
{
return CGSizeMake(90,90);
}
並得到回應:
使用UICollectionViewDelegateFlowLayout方法指定每個單元格所需的大小。 該方法是:
Objc:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;
迅速
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
}
定義所需的CGSize,單元格將采用您定義的寬度和高度。
您的UIViewController必須實現UICollectionViewDelegateFlowLayout協議
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.