首页 > 代码库 > 【IOS】iphone 5s UIImagePickerController未全屏问题

【IOS】iphone 5s UIImagePickerController未全屏问题

今天做到5s打开自定义相机时  取景无法全屏问题  如下图

添加以下代码可以解决问题  将取景框变成全屏

        {
            CGSize screenBounds = [UIScreen mainScreen].bounds.size;
            CGFloat cameraAspectRatio = 4.0f/3.0f;
            CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
            CGFloat scale = screenBounds.height / camViewHeight;
            pickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
            pickerController.cameraViewTransform = CGAffineTransformScale(pickerController.cameraViewTransform, scale, scale);
        }