English 中文(简体)
How to crop image after taken from UIImagePicker Camera?
原标题:

I m trying to allow the user to take 16x9 aspect ratio images to look like they are nice HD photos. I m using the cameraViewOverlay to overlay black bars on both ends, but when the image is taken, how do I crop the top and bottom without resizing or changing the scale of the image?

Thanks.

最佳回答

There are various posts around on how to scale/crop a UIImage you get back from the camera, like this one.

It s a little trickier than you d expect, because camera images are rotated, so you have to think about rotations even if you re just cropping.

问题回答

you can add "picker.imageEditing=YES" to your code when you take the image. Then you have to set the imageView proprieties in the interface builder: Image View Attributes -> View -> Mode -> Aspect fit, or other option as you wish

Check this solution by Ming Yang. https://github.com/myang-git/iOS-Image-Crop-View

It lets the user crop the image by sliding or dragging the edges of a rectangle around the required portion of the image. I presume this code can be modified to suit your cropping need be it automatic or manual.

It is coded in Objective-C. You may have to either code it in Swift or simply build a bridging header to connect the Objective-C code with Swift code.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签