我们如何强制 UIImagePickerController 裁剪方形图像?
我到处寻找,但没有找到可靠的解决方案。谢谢
var imagePickerController: UIImagePickerController = UIImagePickerController();
imagePickerController.allowsEditing = true;
imagePickerController.delegate = self;
imagePickerController.sourceType = sourceType;
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]!) {
profilePictureSelected = true;
profilePictureImageView.image = image;
picker.dismissViewControllerAnimated(true, completion: nil);
}
在收到委托回调之前,您的操作都是正确的,在回调中您需要指定它是您要使用的编辑后的图像。请注意,我在这里使用了不同的委托方法。
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {
if let chosenImage = info[UIImagePickerControllerEditedImage] as? UIImage {
profilePictureSelected = true;
profilePictureImageView.image = chosenImage;
}
picker.dismissViewControllerAnimated(true, completion: nil);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)