我现在把想要显示的图片裁成1024 X 1024
的尺寸。。然后想要放进uiimage里面。uiimageview
和label
是uicollectionviewcell
里的properties.
相关的constraints也设置好了的。
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { let cell = self.imageCollectionView.dequeueReusableCellWithReuseIdentifier("ImageCollectionViewCell", forIndexPath: indexPath) as! ImageCollectionViewCell cell.imageViewContainer.image = self.sourceImages[indexPath.row] let imageSize = self.sourceImages[indexPath.row].size cell.imageViewContainer.frame = CGRectMake(0.0, 0.0, imageSize.width, imageSize.height) cell.imageViewContainer.contentMode = .ScaleAspectFit cell.imageViewContainer.clipsToBounds = true cell.imageTextField.tag = indexPath.row cell.imageTextField.delegate = self return cell }
上面的方法是UICollectionViewDelegate
里面的方法
然后显示的效果是这样的。上下都有spacing
.
求解决方法。
不怕麻烦,用 UIGraphics 自定义大小绘制一下,性能最好。
怕麻烦,看看 UIImageView 的几种图片放缩类型那种适合你。
不知道有没有 get 到你的点