拍摄照片时,我需要看到黑色不透明的底部和顶部条形图。我希望它看起来完全像这样:
这实际上就是我在运行iOS 7的iPhone 5上运行我的代码。但是当我在iPhone 4S(也是iOS 7)上编译我的代码时,底部的条形变得透明 - 视图从顶部变为相机底部,就像现在的相机应用程序。甚至“拍照”按钮也变得透明,就像SnapChat一样。我讨厌这个。我需要改变什么设置才能让我的iPhone 4S上的底栏变得不透明?我正在使用autolayout。
这是在我的viewDidAppear:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
self.anImagePickerController = [UIImagePickerController new];
self.anImagePickerController.delegate = self;
self.anImagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.anImagePickerController.showsCameraControls = YES;
[self presentViewController:self.anImagePickerController animated:NO completion:Nil];
}
答案 0 :(得分:1)
我认为你不能修改UIImagePickerController
的行为。由于较小屏幕设备上的屏幕空间不足,可能会移除黑条。如果您坚持这种行为,则需要使用自定义叠加方法。您将showsCameraControls
设置为NO
,并提供cameraOverlayView
,其行为符合您的要求。在自定义叠加视图中,当用户点按按钮拍照时,您可以在图像选择器控制器上调用takePicture
。
您可以在Apple的示例中看到叠加视图的示例实现: https://developer.apple.com/library/ios/samplecode/PhotoPicker/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010196
答案 1 :(得分:1)
下面的代码将完全符合您的要求。我自己发现了这一点,因为我想要做与你完全相同的事情,并且觉得滚动自己的相机控制器是完全没必要的。
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = YES;
imagePicker.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
imagePicker.delegate = self;
[self presentViewController:imagePicker animated:YES completion:^()
{
for (UIView *subview in imagePicker.view.subviews)
{
if([NSStringFromClass([subview class]) isEqualToString:@"UINavigationTransitionView"])
{
UIView *theView = (UIView *)subview;
for (UIView *subview in theView.subviews)
{
if([NSStringFromClass([subview class]) isEqualToString:@"UIViewControllerWrapperView"])
{
UIView *theView = (UIView *)subview;
for (UIView *subview in theView.subviews)
{
if([NSStringFromClass([subview class]) isEqualToString:@"PLCameraView"])
{
UIView *theView = (UIView *)subview;
for (UIView *subview in theView.subviews)
{
if([NSStringFromClass([subview class]) isEqualToString:@"CAMTopBar"])
{
subview.backgroundColor = [UIColor blackColor];
}
if([NSStringFromClass([subview class]) isEqualToString:@"CAMBottomBar"])
{
subview.backgroundColor = [UIColor blackColor];
}
if([NSStringFromClass([subview class]) isEqualToString:@"PLCropOverlay"])
{
UIView *theView = (UIView *)subview;
for (UIView *subview in theView.subviews)
{
if([NSStringFromClass([subview class]) isEqualToString:@"PLCropOverlayBottomBar"])
{
UIView *theView = (UIView *)subview;
for (UIView *subview in theView.subviews)
{
if([NSStringFromClass([subview class]) isEqualToString:@"PLCropOverlayPreviewBottomBar"])
{
subview.backgroundColor = [UIColor blackColor];
}
}
}
}
}
}
}
}
}
}
}
}
}];
答案 2 :(得分:0)
UIImagePickerController是一个UINavigationController。你抱怨的吧是UINavigationController的toolbar
。您肯定知道,iOS 7默认情况下工具栏是透明的(或至少是半透明的)。