RoundFrameでcollectionViewを設定しようとしていますが、KingFisher(画像キャッシュライブラリ)を使用して取得しています。UICollectionViewCell - Round Downloaded Image
ラウンドコーナー、imageView、またはセル自体で何を設定すべきかわかりません。セルが丸くても、画像は正方形を埋めるように見えます。
これまでのところ、私はこのコードを使用しています(私は画像その平方変更した後、それを設定していけない場合):
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
...
if let path = user.profilePictureURL {
if let url = URL(string: path) {
cell.profilePictureImageView.kf.setImage(with: url)
cell.profilePictureImageView.layer.cornerRadius = cell.profilePictureImageView.frame.width/2.0
}
}
とImageViewの:
class ProfilePicture : UIImageView {
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
self.commonInit()
}
override init(frame: CGRect) {
super.init(frame: frame)
self.commonInit()
}
func commonInit(){
self.layer.masksToBounds = false
self.layer.cornerRadius = self.layer.frame.width/2.0
self.clipsToBounds = true
}
}
しかし、それはダウンロード初めてイメージ、彼らはこのようなもの(セルの背景が青色である)
Ιイメージキャッシングライブラリ(Kingfisher)のコールバックでもこれを呼び出しますが、私はまだ同じエラーです。 (すべての細胞ではなく、ランダムに見える) – PoolHallJunkie