简体   繁体   中英

Customizing the camera View in UIImagePickerController

I wanted to know if there is anyway, I can customize the size of camera view while using UIImagePickerController. Like when I use the camera option to pick up the image, it takes the whole screen. Instead I want it to take just a square window of 250 by 250. So that rest of the stuff of the screen wont be affected, and you will see the view behind the iPhone by camera in just a small window assigned for the picture.

Is it possible.

Here's an example for how to customize the camera overlay by Jason Job.

http://www.musicalgeometry.com/?p=821

or Just do a search for UIImagePickerController camera overlay

in .h file :

#define CAMERA_TRANSFORM_X 0.70
#define CAMERA_TRANSFORM_Y 0.50 

 // For screen dimensions:
   #define SCREEN_WIDTH  100
   #define SCREEN_HEIGTH 100

In .m file ,In ViewWillAppear method :

- (void) viewDidAppear:(BOOL)animated 
{
  OverlayView *overlay = [[OverlayView alloc] initWithFrame:CGRectMake(0, 0,   SCREEN_WIDTH, SCREEN_HEIGTH)];

// Create a new image picker instance:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];

// Set the image picker source:
picker.sourceType = UIImagePickerControllerSourceTypeCamera;

// Hide the controls:
picker.showsCameraControls = NO;
picker.navigationBarHidden = NO;


//[[[self captureManager] previewLayer] setBounds:CGRectMake(0,0,320,480)]; // Make camera view full screen:
picker.wantsFullScreenLayout = normal;
picker.cameraOverlayView =CGRectMinXEdge;

picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
//picker.cameraViewTransform=CGAffineTransformMakeTranslation(CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);
// Insert the overlay:
//picker.cameraOverlayView = overlay;

// Show the picker:
[self presentModalViewController:picker animated:YES];  
[picker release];

[super viewDidAppear:YES];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM