ios – 强制UIImagePickerController裁剪方形图像

前端之家收集整理的这篇文章主要介绍了ios – 强制UIImagePickerController裁剪方形图像前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我们如何强制UII ImagePickerController裁剪正方形图像?

我已经搜索过,我还没有找到一个坚实的解决方案.谢谢

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);
}
原文链接:https://www.f2er.com/iOS/329778.html

猜你在找的iOS相关文章