2009-08-18 98 views
1

還需要什麼才能將圖像顯示爲全桌面視圖寬度?在桌面視圖中拉伸圖像

UIImage *image = [UIImage imageNamed:@"balloon_2.png"]; 
[image stretchableImageWithLeftCapWidth:15 topCapHeight:13]; 
cell.image = image; 

回答

1

stretchableImageWithLeftCapWidth:topCapHeight:返回一個新的UIImage。 你需要做的是這樣

UIImage *image = [UIImage imageNamed:@"balloon_2.png"]; 
UIImage *strImage = [image stretchableImageWithLeftCapWidth:15 topCapHeight:13]; 
cell.image = strImage; 

...或只是分配消息的結果馬上cell.image。

參見:UIImage reference

+0

改變了這一運行時現在得到的異常: 'NSInvalidArgumentException' 的,理由是: '*** - [UICGColor stretchableImageWithLeftCapWidth:topCapHeight:]:無法識別的選擇發送到實例0x529900' 參數不要雖然看起來不錯? – MartinW 2009-08-22 11:17:57