diff --git a/Sources/CropImage/CropImageView.swift b/Sources/CropImage/CropImageView.swift index 8187ca7..53190ad 100644 --- a/Sources/CropImage/CropImageView.swift +++ b/Sources/CropImage/CropImageView.swift @@ -151,6 +151,7 @@ public struct CropImageView: View { RectHoleShape(size: targetSize) .fill(style: FillStyle(eoFill: true)) .foregroundColor(.black.opacity(0.6)) + .animation(.default, value: targetSize) .allowsHitTesting(false) controls { do { diff --git a/Sources/CropImage/RectHoleShape.swift b/Sources/CropImage/RectHoleShape.swift index d77db99..ca317f5 100644 --- a/Sources/CropImage/RectHoleShape.swift +++ b/Sources/CropImage/RectHoleShape.swift @@ -8,7 +8,13 @@ import SwiftUI struct RectHoleShape: Shape { - let size: CGSize + var size: CGSize + + var animatableData: AnimatablePair { + get { .init(size.width, size.height) } + set { size = .init(width: newValue.first, height: newValue.second) } + } + func path(in rect: CGRect) -> Path { let path = CGMutablePath() path.move(to: rect.origin)