我有一个简单的项目,我有一个需要放入视图控制器然后添加到主视图的图像。代码工作正常,但即使设置了内容模式UIViewContentModeScaleAspectFit
,我也没有看到正确缩放的图像。它看起来被拉伸和剪裁。我在这里做错了什么?
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIViewController *controller = [[UIViewController alloc] init];
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a.jpg"]];
imgView.contentMode = UIViewContentModeScaleAspectFit;
[controller.view addSubview:imgView];
[self.view addSubview:controller.view];
}