自定义修改iPhone相机界面

很多情况下,我们需要自定义系统的相机拍照界面, 以下示例代码可以实现定制相机界面, 具体UI自己可以加入

 1 - (void) setup: (UIView *) aView
 2 {
 3     //获取相机界面的view
 4     self.plcameraview = [aView subviewWithClass:NSClassFromString(@"PLCameraView")];
 5     if (!plcameraview) return;
 6 
 7     //相机原有控件全部透明
 8     NSArray *svarray = [plcameraview subviews];
 9     for (int i = 1; i < svarray.count; i++)    [[svarray objectAtIndex:i] setAlpha:0.0f];
10     
11     //加入自己的UI界面
12 #if 1
13     self.navbar = [[[UINavigationBar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)] autorelease];
14     UINavigationItem *navItem = [[[UINavigationItem alloc] init] autorelease];
15     navItem.rightBarButtonItem = BARBUTTON(@"Shoot", @selector(shoot:));
16     navItem.leftBarButtonItem = BARBUTTON(@"Cancel", @selector(dismiss:));
17     
18     [(UINavigationBar *)self.navbar pushNavigationItem:navItem animated:NO];
19     [plcameraview addSubview:self.navbar];
20 #endif
21 }
22 
23 //启动相机
24 - (void) getStarted: (id) sender
25 {
26     UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
27     ipc.sourceType =  UIImagePickerControllerSourceTypeCamera;
28     [self presentModalViewController:ipc animated:YES];    
29     [self performSelector:@selector(setup:) withObject:ipc.view afterDelay:0.5f];
30 }

 

posted @ 2013-08-08 15:07  ubersexual  阅读(579)  评论(0编辑  收藏  举报