我创建了一个图像网格。这些图像的框架是正方形的(CGRects)。不幸的是,图像不成比例地填充了正方形。但我想“裁剪”或“掩盖”给定的图像。这意味着我的框架将仅显示图像的一部分,但按比例正确。我尝试了 UIImageView 的 contentModes 但没有运气。
for(int index = 0; index < (_cols*_rows) ;index++)
{
NSValue *value = [myArray objectAtIndex:index];
CGRect myrect = [value CGRectValue];
UIImageView *myImageView = [[UIImageView alloc] initWithImage:myImage];
myImageView.frame = myrect;
[self addSubview:myImageView];
[myImageView release];
}