Simple ratio based image cropper for SwiftUI
- Xcode 12
- Swift 5.3
ImageCropper is available via Swift Package Manager
Using Xcode 12, go to File -> Swift Packages -> Add Package Dependency and enter https://github.com/marshallino16/ImageCropper
ImageCropper gives you access to a new view called ImageCropperView. It can be integrated within your view body like this :
let ratio = CropperRatio(width: 1, height: 1)
ImageCropperView(image: Image("stock"),
cropRect: nil,
ratio: ratio)
.onCropChanged { (newCrop) in
print(newCrop)
}| Param | Type | Initial Value | Optional |
|---|---|---|---|
| image | Image | no | |
| cropRect | CGRect | nil | yes |
| ratio | CropperRatio | no |
ImageCropperView comes with one modifier
onCropChanged { ... }- Pinch to zoom
ImageCropper is available under the MIT license. See the LICENSE file for more info.
