UIToolBar: how to set custom Text/Background colour [duplicate]
开发者_运维知识库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.
精彩评论