HeroTransitions / Hero

Elegant transition library for iOS & tvOS
https://HeroTransitions.github.io/Hero/
MIT License
22.06k stars 1.73k forks source link

The shadow disappears during the animation #506

Open mimmo00 opened 6 years ago

mimmo00 commented 6 years ago

Hi, when the animation starts, the shadow disappears. This is the code:

`

extension CALayer {
    func applySketchShadow(
        color: UIColor = .black,
        alpha: Float = 0.5,
        x: CGFloat = 0,
        y: CGFloat = 2,
        blur: CGFloat = 4,
        spread: CGFloat = 0)
    {
        shadowColor = color.cgColor
        shadowOpacity = alpha
        shadowOffset = CGSize(width: x, height: y)
        shadowRadius = blur / 2.0
        if spread == 0 {
            shadowPath = nil
        } else {
            let dx = -spread
            let rect = bounds.insetBy(dx: dx, dy: dx)
            shadowPath = UIBezierPath(rect: rect).cgPath
        }
    }
}

...

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: CellId, for: indexPath) as! MyCell

        cell.contentView.layer.cornerRadius = 5.0
        cell.contentView.layer.masksToBounds = true;
        cell.layer.applySketchShadow(
            color: .black,
            alpha: 0.10,
            x: 0,
            y: 6,
            blur: 14,
            spread: 0)
        cell.layer.masksToBounds = false
        cell.clipsToBounds = false
        cell.contentView.hero.id = "CellView-\(indexPath.row)
        ....
return cell
    }
`

I tried to change different parameters, but the shadow always disappears. How can I do? Thank you

rubenvde commented 6 years ago

I got the same issue when I use UIBezierPath to create a corner radius. It only updates after the hero animation has been completed.

michaelalhilly commented 1 year ago

I'm experiencing the same issue during animation on subviews. Transitions are working fine. I've tried all the snapshot options with no success. Can we reopen this?

JoeMatt commented 1 year ago

reopened.

@kishorepran was looking for an issue to fix. Perhaps this?