CameraOverlayView to crop result in UIImagePickerController

When I use UIImagePickerControllerwith cameraOverlayView, can I get only a select area from my overlay view?

http://tinyurl.com/2fqy9nq

+3
source share
1 answer
  • Add a UIImageView as a child of your CameraOverlayView.
  • Create a black PNG size of 320x480. Cut a rectangle in the middle to create a hole (transparent pixels).
  • Assign a PNG image to UIImageView.

Alternatively, you can overwrite your CameraOverlayView - (void)drawRect:(CGRect)rectas follows (untested from my head):

// Request draw context
CGContextRef context = UIGraphicsGetCurrentContext();

// Draw background        
CGContextSetRGBFillColor(context, 0.0f, 0.0f, 0.0f, 1.0f);
CGContextFillRect(context, rect);

// Cut hole
CGContextSetBlendMode(context, kCGBlendModeClear);
CGContextFillRect(context, CGRectMake(40, 40, 100, 100);

- Faces (http://faces.pixelshed.net/). , .

+7

Source: https://habr.com/ru/post/1761061/


All Articles