Hero icon indicating copy to clipboard operation
Hero copied to clipboard

The shadow disappears during the animation

Open mimmo00 opened this issue 7 years ago • 3 comments

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

mimmo00 avatar Jul 28 '18 11:07 mimmo00

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

rubenvde avatar Sep 09 '18 15:09 rubenvde

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?

michaelalhilly avatar Nov 25 '22 20:11 michaelalhilly

reopened.

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

JoeMatt avatar Nov 27 '22 04:11 JoeMatt