开发者社区> 问答> 正文

在集合视图中调整图像大小

override func viewDidLoad() {
        let space:CGFloat = 10.0
        let dimensionwidth = (view.frame.size.width - (2 * space))
        let dimensionheight = (view.frame.size.height - (2 * space))

          flowLayout.minimumInteritemSpacing = space
          flowLayout.minimumLineSpacing = space
          flowLayout.itemSize = CGSize(width: dimensionwidth, height: dimensionheight)
        }

override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CellMemeCollection", for: indexPath) as! CellMemeCollection
        let Meme = self.memes[(indexPath as NSIndexPath).row]

        // Set the name and image
        cell.MemeImage?.image = Meme.memeImage
        cell.MemeImage.sizeThatFits(flowLayout.itemSize)

        return cell
    }

 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

     //    let height = view.frame.size.height
      //   let width = view.frame.size.width

        return CGSize(width: 200, height:400)
     }

我试过所有能让照片看上去更大但没什么变化的东西。我玩了项目的大小,我试着调用函数收集器视图(_收藏品视图:UICollectionView,布局集合视图Layout:UICollectionViewLayout,size ForItemAt indexPath:IndexPath)->CGSize但没有工作,请帮助!

展开
收起
游客5akardh5cojhg 2019-12-08 23:55:25 409 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载