How to make content offset of collection view cell. Code below what do I have but It doesn't work for some reason:
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "pCell", for: indexPath) as! CollectionViewCell
cell.imageView.image = UIImage(named: "1")!
cell.offset(offset: CGPoint(x: 0.0, y: -30.0))
return cell
}
My cell class code:
class CollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!
var image: UIImage = UIImage() {
didSet{
self.imageView.image = image
}
}
func offset(offset: CGPoint) {
self.imageView.frame = self.imageView.bounds.offsetBy(dx: offset.x, dy: offset.y)
}
}
I just can't see any offset when cells are displayed. What I do wrong, guys?