2010-10-27 53 views
0

我想知道是否有,我可以在使用UIImagePickerController時自定義攝像頭視圖的大小。就像當我使用相機選項拾取圖像時,它會佔用整個屏幕。相反,我希望它只需要一個250乘250的方形窗口。這樣屏幕上其餘的內容就不會受到影響,並且您將通過攝像頭在僅分配給圖片的小窗口中看到iPhone背後的視圖。自定義攝像頭在UIImagePickerController中查看

這是可能的。

回答

-1

.h文件搜索:

#define CAMERA_TRANSFORM_X 0.70 
#define CAMERA_TRANSFORM_Y 0.50 

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

.m文件,在ViewWillAppear方法:

- (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]; 
} 
+0

對不起,我的網絡很慢,所以錯誤早些時候.. – 2012-02-27 12:28:50

相關問題