首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 平面设计 > 图形图像 >

自定义UIImagePickerController的照相页面(二)

2013-02-17 
自定义UIImagePickerController的拍照页面(二)以前,写过一篇:自定义UIImagePickerController的拍照页面,这

自定义UIImagePickerController的拍照页面(二)

以前,写过一篇:自定义UIImagePickerController的拍照页面,这篇文章的实现方式与此不同,在开始之前,先来看一下下面这张图:


自定义UIImagePickerController的照相页面(二)

上图对接下来的代码理解会很有帮助,红色的高亮部分是从屏幕上看到的照片的预览图,除了这个之外,他上面的view都可以去掉。

?

要想编辑这些View,需要先找到他们,这里给出了这个方法:

?

- (UIView *)findView:(UIView *)aView withName:(NSString *)name {Class cl = [aView class];NSString *desc = [cl description];if ([name isEqualToString:desc])return aView;for (NSUInteger i = 0; i < [aView.subviews count]; i++) {UIView *subView = [aView.subviews objectAtIndex:i];subView = [self findView:subView withName:name];if (subView)return subView;}return nil;}

?

下面的这段代码给出了比较详细的使用示例:

?

- (void)addSomeElements:(UIViewController *)viewController {//Add the motion view here, PLCameraView and picker.view are both OKUIView *PLCameraView=[self findView:viewController.view withName:@"PLCameraView"];[PLCameraView addSubview:touchView];//[viewController.view addSubview:self.touchView];//You can also try this one.//Add button for Timer capture[PLCameraView addSubview:timerButton];[PLCameraView addSubview:continuousButton];[PLCameraView insertSubview:bottomBarImageView atIndex:1];//Used to hide the transiton, last added view will be the topest layer[PLCameraView addSubview:myTransitionView];//Add label to cropOverlayUIView *cropOverlay=[self findView:PLCameraView withName:@"PLCropOverlay"];[cropOverlay addSubview:lblWatermark];//Get Bottom BarUIView *bottomBar=[self findView:PLCameraView withName:@"PLCropOverlayBottomBar"];//Get ImageView For SaveUIImageView *bottomBarImageForSave = [bottomBar.subviews objectAtIndex:0];//Get Button 0UIButton *retakeButton=[bottomBarImageForSave.subviews objectAtIndex:0];[retakeButton setTitle:@"重拍" forState:UIControlStateNormal];//Get Button 1UIButton *useButton=[bottomBarImageForSave.subviews objectAtIndex:1];[useButton setTitle:@"保存" forState:UIControlStateNormal];//Get ImageView For CameraUIImageView *bottomBarImageForCamera = [bottomBar.subviews objectAtIndex:1];//Set Bottom Bar ImageUIImage *image=[[UIImage alloc] initWithContentsOfFile:[[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"BottomBar.png"]];bottomBarImageForCamera.image=image;[image release];//Get Button 0(The Capture Button)UIButton *cameraButton=[bottomBarImageForCamera.subviews objectAtIndex:0];[cameraButton addTarget:self action:@selector(hideTouchView) forControlEvents:UIControlEventTouchUpInside];//Get Button 1UIButton *cancelButton=[bottomBarImageForCamera.subviews objectAtIndex:1];[cancelButton setTitle:@"取消" forState:UIControlStateNormal];[cancelButton addTarget:self action:@selector(hideTouchView) forControlEvents:UIControlEventTouchUpInside];}

?自定义UIImagePickerController的照相页面(二)

?
自定义UIImagePickerController的照相页面(二)

热点排行