1 , 自定义相机,拿到照片,校正方向
AVCapturePhotoCaptureDelegate 的这个代理方法
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?)
拿照片,
extension ZLCustomCamera: AVCapturePhotoCaptureDelegate {
public func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
if error != nil {
return
}
if let imgData = photo.fileDataRepresentation(){
self.session.stopRunning()
if let img = UIImage(data: imgData){
self.takedImage = img.fixOrientation()
}
self.takedImageView.image = self.takedImage
self.takedImageView.isHidden = false
self.resetSubViewStatus()
}
}
}
拿到照片后,让照片的头部朝上
extension UIImage {
// 修复转向
func fixOrientation() -> UIImage {
if self.imageOrientation == .up {
return self
}
var transform = CGAffineTransform.identity
switch self.imageOrientation {
case .down, .downMirrored:
transform &#