开发者

UIToolBar: how to set custom Text/Background colour [duplicate]

This question already has answers here: Closed 11 years ago.

开发者_运维知识库Possible Duplicate:

Can I give a UIToolBar a custom background in my iPhone app?

Hi everybody,

I'm working on a iOS project with a custom Toolbar. I'm having the following problem: The color values for the icons are simply ignored during run time on he device. The text is always white (so i think only the grayscale value is used). Does anyone of you know how to solve the problem?

thx in advance.


You can customize UIToolBar.


UIImage *myImage = [UIImage imageNamed:@"ToolBar_background.png"];
UIImageView *anImageView = [[UIImageView alloc] initWithImage:myImage];
[aToolBar insertSubview:anImageView atIndex:0];
[anImageView release];

Create 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];

Add your button to the toolbar.


[aToolBar addSubview:myButton];

Try this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜