1
我創建了一個圖像網格。 這些圖像的幀是正方形(CGRects)。不幸的是,這些圖像不成比例地適合廣場。 但我想「裁剪」或「掩蓋」給定的圖像。這意味着我的框架將只顯示圖像的一部分,但按比例正確。我嘗試了UIImageView的contentModes,但沒有運氣。裁剪圖像objective-c
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];
}
試過,但圖像/幀只是相互重疊... – algro 2010-10-11 08:41:52
嗯,檢查imageViews的「clipsToBounds」屬性設置爲YES。 – zem 2010-10-11 08:49:28