Hero
Hero copied to clipboard
The shadow disappears during the animation
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
I got the same issue when I use UIBezierPath to create a corner radius. It only updates after the hero animation has been completed.
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?
reopened.
@kishorepran was looking for an issue to fix. Perhaps this?