2017-05-25 64 views

回答

0

使用UICollectionViewDelegateFlowLayout方法。

func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { 

     let width : CGFloat 
     let height : CGFloat 

     if indexPath.item == 0 { 
      width = 100 
      height = 100 
     } else { 
      width = 50 
      height = 50 
     } 
     return CGSizeMake(width, height) 

} 
+0

它不起作用 – Ujesh

+0

你可以在這裏粘貼你的cellforRowAtItem和numberOfItemsInSections委託方法嗎? –

1

,而無需創建集合的自定義佈局查看它是不可能達到你想要什麼。

您可以使用其委託方法sizeforitematindexpath創建自定義單元格大小。

此外,檢查this鏈接,這有助於創建自定義佈局。

+0

Okey,我仍然在尋找像比例尺單元一樣簡單的方法。自定義佈局是我的最後選擇。謝謝 – Ujesh

+0

@Ujesh檢查這個鏈接https://github.com/bryceredd/RFQuiltLayout。 –

+0

@Ujesh CollectionView是用於佈局。沒有其他方法可以實現它。否則,另一種方式是ScrollView + UIView,這會讓事情變得很難。 –

相關問題