let controller =UIImagePickerController.init()
if index == 0 {
controller.sourceType= .camera
} else {
controller.sourceType= .photoLibrary
}
// default value is an array containing kUTTypeImage.文档说明默认值是此,故不需设置
// controller.mediaTypes = [kUTTypeImage]
controller.cropSize = CGSize(width: 300, height: 300)
controller.cropMode = .square//DZNPhotoEditorViewControllerCropModeSquare
controller.finalizationBlock = { [weak self] picker, info -> Void in
QLDebug(picker)
QLDebug(info)
if let strongSelf = self {
var image :UIImage? = nil
if strongSelf.needEdit {
image = info?[UIImagePickerControllerEditedImage] as? UIImage
} else {
image = info?[UIImagePickerControllerOriginalImage]as?UIImage
}
image = image?.fixOrientation()
if let myImage = image {
// 拿到image保存起来
strongSelf.addImageButton.setBackgroundImage(myImage, for: .normal)
strongSelf.setTupleOfSomeone(number:8, value: image)
QLDebug(myImage)
strongSelf.dismiss(animated: true, completion: nil)
}
}
}
controller.cancellationBlock = { [weak self] picker in
QLDebug(picker?.viewControllers)
if let strongSelf = self {
if picker?.viewControllers.count == 1 {
strongSelf.dismiss(animated: true, completion: nil)
} else {
picker?.popViewController(animated: true)
}
}
}
//UIApplication.shared.statusBarStyle = .default
self.statusBarColor=KFXStatusBarColor.black
self.present(controller, animated: true, completion: nil)
}
网友评论