[英]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.