我想在点击缩略图时显示全屏图像.现在我正在呈现一个模态视图控制器,但图像不在屏幕中心:

这是我在模态视图控制器中用来呈现视图控制器的代码:
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];
Run Code Online (Sandbox Code Playgroud)
如何在视图控制器中居中显示此图像?
小智 4
您是否尝试过 [image view setCenter:self.view.center]
根据屏幕居中,但如果您想以 modalCon 为中心,则替换self.view为modalCon.view
| 归档时间: |
|
| 查看次数: |
4174 次 |
| 最近记录: |