【发布时间】:2020-03-30 00:15:23
【问题描述】:
我想在容器中插入一张图片。 但是当我运行这段代码时
//MARK: - UICollectionViewDataSource protocol
// tell the collection view how many cells to make
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return self.items.count
}
//make a cell for each cell index path
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
//get a reference to our storyboard cell
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath as IndexPath) as! AppIconViewCell
// Use the outlet in our custom class to get a reference to the UILabel in the cell
cell.myLabel.text = self.items[indexPath.item]
cell.ImageView.image = UIImage.init(named: "page-01")
//cell.backgroundColor = UIColor.cyan
cell.layer.borderColor = UIColor.black.cgColor
cell.layer.borderWidth = 1
cell.layer.cornerRadius = 8
return cell
}
我的理解是图像大于框架导致框架扩大。
我怎样才能在里面设置一个图像,以便它适合第一张图像的框?
【问题讨论】:
标签: ios swift uicollectionview uicollectionviewcell