我有一个图像(从我们的服务器获取)我想放入 UIImageView。图像为 373x500。UIImageView 是 443x290 并且视图正在拉伸它。
UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,
0,
500,
300)];
myImageView.image = [UIImage imageWithData:photoData];
myImageView.backgroundColor = [UIColor viewBackgroundColor];
myImageView.contentMode = UIViewContentModeScaleAspectFit;
NSLog(@"myImageView.image.size: %@", NSStringFromCGSize(myImageView.image.size));
NSLog(@"myImageView.frame.size: %@", NSStringFromCGSize(myImageView.frame.size));
[wrapperView addSubview:myImageView];
日志内容:
2012-05-09 11:32:52.621[89145:1a303] myImageView.image.size: {373, 500}
2012-05-09 11:32:52.622[89145:1a303] myImageView.frame.size: {443, 290}
好像:
“UIViewContentModeScaleAspectFit”不应该告诉它保持比例而不拉伸图像吗?