1

我创建了一个图像网格。这些图像的框架是正方形的(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];

}
4

1 回答 1

1

你确定 contentMode 不会做你想做的事吗?如果我理解正确,UIViewContentModeScaleAspectFill将完全按照您的描述进行。

于 2010-10-10T21:31:25.113 回答