我有一個梯度的形象,在藍色。它是100px(高度)×1px(寬度)。現在我試圖將其用作突出顯示狀態的背景圖像。但不知何故,它在運行時會變成橙色。這裏可能有什麼問題?按鈕的高度爲40像素,所以將其設置藍色漸變的圖像錯誤拉伸成橙色漸變圖像的UIButton
UIImage *image = [UIImage imageNamed:@"pressed.png"];
UIImage *stretchedImage = [[UIImage imageWithImage:image scaledToSize:frame.size] stretchableImageWithLeftCapWidth:0 topCapHeight:0];
[button setBackgroundImage:stretchedImage forState:UIControlStateHighlighted];
可以還張貼pressed.png形象? – 2012-04-16 07:05:02
抱歉我們對圖片有財產保護,無法分享。 – tom 2012-04-16 07:15:18
您可以重新創建對其他*圖片可以共享的效果嗎?如果沒有其他問題,你可以解決問題。 – ChrisF 2012-04-16 10:57:14