Make UIImageView a 'Window' into the Image, Not Squeeze It? Only Shows Small Section

StackOverflow https://stackoverflow.com/questions/21585057

  •  07-10-2022
  •  | 
  •  

Вопрос

I've got a UIImageView which gets image from the camera;

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [imageView setImage:image];
    [self dismissViewControllerAnimated:YES completion:NULL];
}

How do I make it so the image does not squeeze into the UIImageview, but rather acts as a 'window' so you only see a certain section of the image, that is the size of my UIImageView?

Thanks for any help, all is appreciated!

Это было полезно?

Решение

imageview.contentMode = UIViewContentModeCenter;

will centre the image in the view, you can adjust the size of the view then to hide or show more.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top