2009-06-04 129 views

回答

33

一種常見的技術是將圖像用於背景。其實你可以使用可伸縮的圖像:

- (void)viewDidLoad { 
    UIImage *blueImage = [UIImage imageNamed:@"blueButton.png"]; 
    UIImage *blueButtonImage = [blueImage stretchableImageWithLeftCapWidth:12 topCapHeight:0]; 
    [myButton setBackgroundImage:blueButtonImage forState:UIControlStateHighlighted]; 
} 

原始圖像:

alt text

最終結果是:

alt text

+0

謝謝,它的工作。 – ebaccount 2009-06-04 19:16:20

2

假設您的意思是UIButton,您只能使用setTitleColor:forState:更改標題顏色。

您無法更改背景顏色或形狀。你必須爲此創建自己的控制。

0

我就開始iphonedevsdk.com this thread

希望我們會在那裏得到答案,如果不在這裏。

相關問題