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

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

  •  07-10-2022
  •  | 
  •  

Pergunta

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!

Foi útil?

Solução

imageview.contentMode = UIViewContentModeCenter;

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top