【发布时间】:2015-04-08 17:22:31
【问题描述】:
我正在尝试向此 UIImagePickerController 实例添加叠加层,但结果是叠加层偏离中心。
我创建了一个简单的红色正方形 (300x300 pt) 来举例说明问题并用作叠加层,并将其添加到相机叠加层中,使用如下:
CGRect bounds = [[UIScreen mainScreen] bounds];
UIView *containerOverlay = [[UIView alloc] initWithFrame:bounds];
UIImage *overlay = [UIImage imageNamed:@"red"];
UIImageView *overlayView = [[UIImageView alloc] initWithImage:overlay];
CGFloat midX = CGRectGetMidX(bounds);
CGFloat midY = CGRectGetMidY(bounds);
CGPoint center = CGPointMake(midX, midY);
overlayView.center = center;
[containerOverlay addSubview:overlayView];
[_camera setCameraOverlayView:containerOverlay];
这是实时预览中显示的内容...完全偏离垂直中心。
令人惊讶的是,当我拍照并且 iOS 向我显示已经拍摄的照片时,叠加层神奇地居中......
如何将叠加层置于实时摄像头的中心?
【问题讨论】:
标签: ios cocoa-touch uiimagepickercontroller overlay