[英]UICollectionView — scaling cells to fit the screen
您可以使用此collectionView流布局委托方法来实现此目的
func collectionView(_ collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAt indexPath: IndexPath) -> CGSize {
if UIDevice.current.userInterfaceIdiom == .pad{
// here return cell size for iPad.
return CGSize(width:collectionView.bounds.width / 2 , height:100)
}else{
// here return cell size for iPhone
return CGSize(width:collectionView.bounds.width, height:100)
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.