This was great help! I had issues with the offset after scaling, when the image exceeded the bounds of the view I updated the logic for handling the bounds to something like this, and proved to be an improvment GeometryReader { proxy in let frame = proxy.frame(in: .named("cropView")) Color.clear.onChange(of: isInteracting) { isDragging in withAnimation(.easeOut) { let horizontalOverflow = (frame.width - size.width) / 2 offset.width = min(horizontalOverflow, max(-horizontalOverflow, offset.width)) let verticalOverflow = (frame.height - size.height) / 2 offset.height = min(verticalOverflow, max(-verticalOverflow, offset.height)) } if !isDragging { previousOffset = offset } } }
@geneva521311 ай бұрын
For anyone using this and pulling their hair out why the quality of the cropped image is very low and pixelated, I've found a solution: Add ' renderer.scale = 10.0' after 'let renderer = ....' in the CropView struct.
@FirstPlaceFilms8 ай бұрын
Thank You! Just spent hours looking for this
@edlar Жыл бұрын
Просто лучший! 🔥👍
@jakubhaumer1069 Жыл бұрын
Great materials for learning and understanding the basis how croppers can work but at slightly deeper level, the cropper is not reliable and can be often pretty buggy. However, when further modifications are applied, can serve at usable level.
@kadmieljoseph170 Жыл бұрын
Wow, you're amazing... the simplicity, consistency and creativity, just amazing. Meanwhile, I was thinking if is possible to run Xcode on windows OS operating systems, because I would love to try it out...
@chimansong8653 Жыл бұрын
Thanks for a great video. Question! when I zoom in after zoom out it does not scale down in the same ratio of pitch movement. it relatively smaller compared to zoom in action. Any advice on this?
Жыл бұрын
The Best! 👏✨🚀
@alenayoutube1574 Жыл бұрын
Nice video sir , i success fully completed this project , its working , thanks for doing this , But i need to learn more about @viewbuilder and more about different keywords , any way thankyou. sir Those who cant zoom press option button to activate 2 finger zoom gesture and drag mouse
@manasvijaywargiya8218 Жыл бұрын
It was really awesome 😀🔥 tutorial. Thanks Kavsoft ✌
@tonycyber Жыл бұрын
if the image were to be upload to firebase the cropped image would be uploaded, right? because i saw that you converted the View to Image. i just want to make sure the cropped Image is a new Image, not just a image that was zoomed in.
@ordozgoite9 ай бұрын
Thank you so much!
@fitlifeeroАй бұрын
This code works amazing 🤩 but I need free crop, how do I make it
@steam9583 Жыл бұрын
Just genius...
@andrejkling3886 Жыл бұрын
Awesome... thank you 👍🎄
@sphericalwave Жыл бұрын
very nice
@RyuuzakiJulio Жыл бұрын
What needs to be changed to avoid the dialog and automatically do a rectacle crop?
@pavelbondar137 ай бұрын
try to make CropView var image: UIImage? -> @Binding var image: UIImage?
@santhoshVnair Жыл бұрын
Nice. UIImage is part of UIKit and it works only in iOS. So, this will not work for Mac. I see PhotosPicker supports SwiftUI Image. So, if you can update this from selectedImage: UIImage? to selectedImage: Image? - then this will work for iOS and Mac, right? May be an idea for another video?
@Kavsoft Жыл бұрын
I made this video specifically for iOS; may I note this for future video lists?
@craigmiller Жыл бұрын
You have to adapt it a little bit, but it's not too difficult. Replace UIImage with NSImage, change some of the dialogs to be macOSish instead of iOSish. Have to add support for the mouse wheel and/or add a slider for the zoom function.