2012-07-24 22 views
0

我需要加載一個單元格中的圖像,我沿着我的圖像得到一個白色邊框。我從鏈接調用圖像,它看起來像這樣。UIImageView中的內容模式問題,當它設置爲ASpectFill

enter image description here

但我的形象看起來像

enter image description here

我得到我的圖像白色邊框的左,右side.Here是我的形象代碼

UIImageView *item=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 115, 130)]; 

    NSString *imgstring=[NSString stringWithFormat: @"%@",[[mutarray objectAtIndex:indexPath.row ] valueForKey:@"imgurl"]]; 

    NSURL *imgurl=[NSURL URLWithString:imgstring]; 

    UIImage *image=[UIImage imageWithData:[NSData dataWithContentsOfURL:imgurl]]; 


    [item setBackgroundColor:[UIColor clearColor]]; 
    item.contentMode=UIViewContentModeScaleToFill; 
    [item setImage:image]; 
    [cell.contentView addSubview:item]; 

請指導...

+0

我猜你的形象圖幀大小是錯誤的。嘗試給一些背景顏色來測試。像黃色到單元格背景和綠色到圖像背景。然後將這些圖像添加到此處,這對解決您問題的訪問者會有所幫助。 – Mrunal 2012-07-24 15:05:31

+0

我試過,但都一樣.. – Dany 2012-07-24 15:18:40

回答

0

您可以通過編輯webimage解決它becaust它具有白色背景,ü可以添加以下代碼通過給

item.backgroundcolor=[UIColor blackcolor]; 

希望它可以幫助區分圖像..

4

那些白色的邊框在你發佈的圖片中,這就是它們出現在iOS中的原因。在照片編輯器中打開該圖片,您會看到。

+0

你可以參考鏈接,例如... http:\/\/shop.minora.com.sg \/img \/p \/72-117-large.jpg ..這是原始圖像..u可以看到在那個圖像中沒有白色邊框.. – Dany 2012-07-24 15:19:54

+2

嗯,是的,有...鏈接與您在問題中發佈的鏈接完全相同:300x300像素,約37像素白色在每邊。 – borrrden 2012-07-24 15:21:42

+0

圖像兩側均有白色邊框。 – manileo86 2012-07-24 15:28:52