1
可能重複:
Can I give a UIToolBar a custom background in my iPhone app?UIToolBar:如何設置自定義文字/背景色
大家好,
我工作的一個項目的iOS與自定義工具欄。我遇到以下問題: 在設備上運行時,圖標的顏色值會被忽略。文本總是白色的(所以我認爲只有灰度值被使用)。你們有誰知道如何解決這個問題?
thx提前。
可能重複:
Can I give a UIToolBar a custom background in my iPhone app?UIToolBar:如何設置自定義文字/背景色
大家好,
我工作的一個項目的iOS與自定義工具欄。我遇到以下問題: 在設備上運行時,圖標的顏色值會被忽略。文本總是白色的(所以我認爲只有灰度值被使用)。你們有誰知道如何解決這個問題?
thx提前。
您可以自定義UIToolBar。
UIImage *myImage = [UIImage imageNamed:@"ToolBar_background.png"];
UIImageView *anImageView = [[UIImageView alloc] initWithImage:myImage];
[aToolBar insertSubview:anImageView atIndex:0];
[anImageView release];
創建的UIButton
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setImage:[UIImage imageNamed:@"buttonImage.png"] forState:UIControlStateNormal];
[myButton setFrame:CGRectMake(x,y,width,height)];[myButton addTarget:self action:@selector(myMethod) forControlEvents:UIControlEventTouchUpInside];
添加您的按鈕工具欄。
[aToolBar addSubview:myButton];
試試這個。
您是否設置了色調? – 2011-03-18 11:50:34
請參閱[this](http://stackoverflow.com/questions/1941103/can-i-give-a-uitoolbar-a-custom-background-in-my-iphone-app)線程。 – Vin 2011-03-18 11:46:41