• The problem

    Not all photos UIImagePickerController can handle, for the following reasons:

    1. You can’t experience innovation if the product is not a little messy

    2. How can we reflect our intentions if we don’t design a single point

    3. Operation: This experience is different from a certain treasure a certain letter??

    4. Development: I was forced to be a boss!! 1.2.3. Big factories can do it under pressure, but you can’t

  • Ideas:

    Custom camera: What about the live scene in UIImagePickerController?

    Plan on AVCaptureSession + AVCaptureVideoPreviewLayer is generally adopted

    AVCaptureVideoPreviewLayer inheritance CALayer, set bounds, frame, can meet the demand of simple

    But, in such cases as horizontal and vertical screen switching, iPhone and iPad sharing, view effect adjustment (after all, the above 1.2. Discourse power is generally greater than development), the frame mode is not constrained to be realistic

    Each view has a layer properties, customize the view layer for AVCaptureVideoPreviewLayer, view constraint adjustment to change the frame

  • serving

    • Define a View

      @interface AVPreView : UIView
      
      @end
      Copy the code
    • Set the layerClass

      + (Class)layerClass {
          return [AVCaptureVideoPreviewLayer class];
      }
      Copy the code
    • In order to real time scene, layer AVCaptureVideoPreviewLayer is need to set up a session

      // Set @property (nonatomic, strong) AVCaptureSession *session; // Getter & Setter - (AVCaptureSession *)session { return [(AVCaptureVideoPreviewLayer *)self.layer session]; } - (void)setSession:(AVCaptureSession *)session { [(AVCaptureVideoPreviewLayer *)self.layer setSession:session]; }Copy the code
    • You need to set a focus or something, and then you need to convert whatever point you touch on the view to the position of the camera

      -(CGPoint)captureDevicePointForPoint:(CGPoint)point{ AVCaptureVideoPreviewLayer *layer = (AVCaptureVideoPreviewLayer *)self.layer; / / to the position of the screen click into the position of the camera return [layer captureDevicePointOfInterestForPoint: point]; }Copy the code
  • Game Over. Code is no good.