2016-08-12 10 views
0

UICollectionViewCellの上の位置を設定して、余分な間隔を取り除きたい。Xcode:UICollectionViewCellの位置を調整する

デザイン時に一番上の位置を設定しようとしていますが、無効になっています。

Screenshot 1

は、実行時には、トップの位置は、その後、あまりにも空のスペースがたくさんあります0に設定されています。この問題を解決する方法

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

     . . . 

     if device_type == "iPhone4-Series" { 
      mElementSize = CGSizeMake(60, 60) 
     } 
     . . . 
    } 

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,minimumInteritemSpacingForSectionAtIndex section: NSInteger) -> CGFloat { 

     if device_type == "iPhone4-Series" { 
      return 5.0 
     } 
    . . . 
    } 

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout,minimumLineSpacingForSectionAtIndex section: NSInteger) -> CGFloat { 

     if device_type == "iPhone4-Series" { 
      return 5.0 
     } 
    . . . 
    } 

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout:UICollectionViewLayout, insetForSectionAtIndex section: NSInteger) -> UIEdgeInsets { 

     if device_type == "iPhone4-Series" { 
      return UIEdgeInsetsMake(0,40,2,40) 
     } 
    . . . 
} 

Screenshot 2

Screenshot 3

答えて

0

UICollectionViewFlowLayoutでこれらのプロパティを見て試してみてください。

  • minimumLineSpacing

  • minimumInteritemSpacing

  • sectionInset

関連する問題