I want to show a fullscreen image when a thumbnail is tapped. Right now I'm presenting a modal view controller, but the image is not centered in the screen:
Here's the code I'm using in the modal view controller to present the view controller:
UIViewController *modalCon = [[UIViewController alloc] init];
modalCon.view.backgroundColor=[UIColor blackColor];
modalCon.view.userInteractionEnabled=YES;
UIImageView *imageView = [[UIImageView alloc] initWithFrame:modalCon.view.frame];
imageView.contentMode=UIViewContentModeScaleAspectFit;
imageView.image=coverImage.image;
[modalCon.view addSubview:imageView];
UITapGestureRecognizer *modalTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissModalView)];
[modalCon.view addGestureRecognizer:modalTap];
[self presentViewController:modalCon animated:YES completion:nil];
How do I get this image centered in the view controller?
did you try [image view setCenter:self.view.center]
that one centres according to screen but if you want to centre to modalCon then replace self.view
to modalCon.view
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With