1

I am using IGListKit with my UICollectionView. For now the CollectionView is pretty simple, as it only have one cell per section. That cell contains an inner horizontal UICollectionView as an image slideshow.

As I need some shadowing around my entire sections, I am using Decoration Views, and apply it a border shadow: layer.shadowPath

I noticed something weird, the shadow's opacity changes upon the picture currently displayed in the slideshow. If the picture (or a portion of the picture) is bright, you can see the shadow opacity changing.

I don't know if it is something I can fix.

You can clearly see that if I take a screenshot while swiping pictures in the slideshow, the shadow on the top is darker on one side.

enter image description here

Code for decoration view:

class FeedItemBackgroundShadowView: UICollectionReusableView {

    // MARK: Initialization

    ... Constructors calling setup

    // MARK: Setup

    override func layoutSubviews() {
        super.layoutSubviews()
        self.layer.shadowPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: Constants.cornerRadius).cgPath
    }

    func setup() {
        self.layer.cornerRadius = 12.0
        self.layer.backgroundColor = UIColor.white.cgColor
        self.layer.shadowColor = UIColor.black.cgColor
        self.layer.shadowOffset = CGSize(width: 0.0, height: 2.5)
        self.layer.shadowRadius = 12.0
        self.layer.shadowOpacity = 0.35
}

Rest of the code a simply UICollectionViewCells that embed a UICollectionView

Scaraux
  • 3,841
  • 4
  • 40
  • 80
  • It might be about `override func layoutSubviews` method. Can you check when exactly that method is triggered as you scroll horizontally? The shadow behaviour might be strange until that method is triggered and actual bezierpath is added as a layer. – emrepun Dec 10 '18 at 22:46
  • The `layoutSubviews` in the decoration cell (`FeedItemBackgroundShadowView`) is only called when I scroll vertically. It is not called when I swipe horizontally in the cells. – Scaraux Dec 10 '18 at 22:48

1 Answers1

1

Are you certain it isn't an optical illusion?

enter image description here

Alexander Telegin
  • 665
  • 1
  • 7
  • 22