【发布时间】:2013-08-19 10:54:21
【问题描述】:
大家好,我面临一个问题。 在我的应用程序中,我想裁剪从相机拍摄的图像区域。 因此,我使用的是 UIImagePickerController 和它的 cameraOverlayView。
问题是在 iPhone 4S、iPad、iPod 上 - “状态栏”不透明。 在第二台 iPad 上,相机中的“状态栏”是透明的。 不知道如何访问 UIImagePickerController 的状态栏?
在我的代码中,我进行了一些高度计算,以防透明,我错误地减去了额外的大小。而且我无法弄清楚“拍摄区域”内图像的大小。
这里有一些代码:
+(CGFloat) statusBarYSize
{
CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
return MIN(statusBarSize.width, statusBarSize.height);
}
+(CGRect)maxRectForPicker:(UIImagePickerController*)picker
{
CGRect maxFrame = picker.cameraOverlayView.frame;
#warning @"Check that coefficient is equal to such value everywhere...)"
if (!picker.toolbar.translucent)
maxFrame.size.height -=([self statusBarYSize]*2.5); // If transparent should not be subtracted!
return maxFrame;
}
以下是图片链接:
iPhone 的图像。相机具有全屏尺寸 - 状态栏。
https://www.dropbox.com/s/7b405h5cavrf819/CorrectSubstraction.jpg
iPad 的图像。摄像头占据整个屏幕。
https://www.dropbox.com/s/7rekl8xen1z3s9b/ShouldNotSubstract.jpg
提前非常感谢。 夏尔黑
【问题讨论】:
标签: ios camera uiimagepickercontroller uistatusbar