1

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.

Community
  • 1
  • 1
blunzn
  • 15
  • 1
  • 3

1 Answers1

3

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.

Adarsh V C
  • 2,314
  • 1
  • 20
  • 37