我想在点击缩略图时显示全屏图像.现在我正在呈现一个模态视图控制器,但图像不在屏幕中心:
这是我在模态视图控制器中用来呈现视图控制器的代码:
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];
如何在视图控制器中居中显示此图像?