I have an imageview inside of a collectionview cell. I tried a few processors and they work, but the RoundCornerImageProcessor doesn't work for me..
let processor = RoundCornerImageProcessor(cornerRadius: 20)
imageView.kf.setImage(with: url, placeholder: nil, options: [.processor(processor)])

It works for me well, at least in the demo app.
Any more information?
@onevcat I wish that I could give you more information, but the fact is every processor works for me except the rounded image. But when I have an imageview outside of a collection view cell then the roundedcorner processor does work properly..
Maybe take a look at the demo app in Kingfisher, which is also using image view within a collection cell.
Could it be related to this? https://github.com/onevcat/Kingfisher/blob/master/Demo/Kingfisher-Demo/CollectionViewCell.swift#L37
@onevcat sadly enough it's not related to it. I had these properties already
Can you build a sample app which could reproduce it? I'd like to have a look at it if there is a way to reproduce on my side.
Sorry for the late reaction. The problem was that the size of the image wasn't right to accomplish what I wanted. So I needed a resize processor as well.
let processor = ResizingImageProcessor(targetSize: CGSize(width: 300, height: 300)) >> RoundCornerImageProcessor(cornerRadius: 150)
imageView.kf.setImage(with: url, placeholder: nil, options: [.processor(processor)])
This works, but it shows the shadow behind the collectionviewcell, which is not that nice :(
Good to know that.
You mentioned about the shadow, which I guess is added by UIKit of tvOS to show a focus indicator?
It seems we do not have much to do with it since it is a system behavior and a almost a black-box to us. :(
Maybe it would be better to use a small round-corner image instead of a fully round image to get a nice visual effect.
@stijnwesterhof Nice man!
If someone uses it:
extension UIImageView {
func download(url: String?, rounded: Bool = true) {
guard let _url = url else {
return
}
if rounded {
let processor = ResizingImageProcessor(referenceSize: self.frame.size) >> RoundCornerImageProcessor(cornerRadius: self.frame.size.width / 2)
self.kf.setImage(with: URL(string: _url), placeholder: nil, options: [.processor(processor)])
} else {
self.kf.setImage(with: URL(string: _url))
}
}
}
Most helpful comment
@stijnwesterhof Nice man!
If someone uses it: