将UIImagePickerController叠加层置于横向中

时间:2014-01-31 13:26:14

标签: ios camera uiimageview uiimage uiimagepickercontroller

我正试图将我的叠加正确地放在横向模式上,到目前为止,这就是我所拥有的。:

So the image appears, but it's not filling all the screen...

所以图像出现了,但它不是填充横向上的所有屏幕......

以下是一些代码:

- (IBAction)takeSecondPhotoAction:(id)sender {

    UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init];
    photoPicker.delegate = self;
    photoPicker.sourceType = UIImagePickerControllerSourceTypeCamera;

        UIImageView * overlay;


        if(self.firstPhotoImage.imageOrientation == UIImageOrientationUp || self.firstPhotoImage.imageOrientation == UIImageOrientationDown){
            overlay = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            [overlay setImage:self.firstPhotoImage];
            overlay.transform = CGAffineTransformMakeRotation(1.57);
            [overlay setContentMode:UIViewContentModeScaleAspectFit];
        }else{
            overlay = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
            [overlay setContentMode:UIViewContentModeScaleAspectFit];
            [overlay setImage:self.firstPhotoImage];
        }

        overlay.alpha = alphaValue;

        photoPicker.cameraOverlayView = overlay;


    [self presentViewController:photoPicker animated:YES completion:NULL];
}

所以基本上,我首先询问图像是横向还是纵向,然后我开始填充图像,你可以在横向模式下看到,首先我旋转叠加然后我指定内容模式。

所以,我认为错误在于:[overlay setContentMode:UIViewContentModeScaleAspectFit];

有没有办法轻松妥善地完成这项工作? 感谢

0 个答案:

没有答案