[英]How to Display 3*3 CollectionView Cell For Dynamic Height in Swift
I want to show 3*3 Collection View Dynamic Height cell any one known how to display this 我想显示3 * 3集合视图动态高度单元格的任何一个已知的显示方式
thanks in Advance.!!! 提前致谢。!!!
Here's what you can use to have 3 * 3 Collection View
regarding iPhone screen size (assuming that your collectionView frame is set according to screen size) : 这是关于iPhone屏幕尺寸可使用的
3 * 3 Collection View
(假设您的collectionView框架是根据屏幕尺寸设置的):
Swift
迅速
optional func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
var spaceBetweenCells = 12
var width = (self.collectionView.frame.size.width - spaceBetweenCells * 3) / 3
var height = (self.collectionView.frame.size.height - spaceBetweenCells * 3) / 3
return CGSizeMake(width, height)
}
Objective C
目标C
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout *)collectionViewLayout
sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat spaceBetweenCells = 12;
CGFloat width = (self.collectionView.frame.size.width - spaceBetweenCells*3) / 3;
CGFloat height = (self.collectionView.frame.size.height - spaceBetweenCells*3) / 3;
return CGSizeMake(width, height);
}
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.