I think crop can be done when UIImagePickerController allowsEditing=YES, but if you resize the background transparent png, the ratio of images will be strange.
I will crop this original image like the one below.
Perhaps because the transparent part of the background disappears, the circle is crushed and placed in the imageview.
After selecting it in the UIImagePickerController, it is set to 140x140px UIImageView.
In the above capture, the black part is 140x140px UIImageView.
funcimagePickerController (picker: UIImagePickerController, DidFinishPickingImage: UIImage!, editingInfo: [NSObject: AnyObject]!) {
self.uiimageview.image=image
println(image)
println(editingInfo)
}
The UIImage and editingInfo logs were as follows.
<UIImage:0x17409d100>size{1065,1242} orientation0scale1.000000
{
UIImagePickerControllerCropRect="NSRect: {{0,6}, {243,283}}";
UIImagePickerControllerOriginalImage="<UIImage:0x17409c660>size {244,500} orientation0scale1.0000";
UIImagePickerControllerReferenceURL="assets-library://asset/asset.PNG?id=2AE8222F-5332-468D-BE25-5CE826E0ABEC&ext=PNG";
}
If anyone knows how to install this in UIImageView without changing the ratio, I would appreciate it if you could let me know.
Thank you for your cooperation.
swift
I think it has nothing to do with crop and background transparency.
in advance
uiimageview.contentMode=.ScaleAspectFit
Why don't you set it up with ?
This allows you to view images in the maximum size in the UIImageView
with a fixed aspect ratio.
© 2024 OneMinuteCode. All rights reserved.