0

I would like to create a UIBarButtonItem with an icon and text. I've seen this solution and this one but when you set the background image it doesn't draw a border.

I don't really want to draw a border (that looks like the "Plain" style one) with my icon on it. Is there another way around this?

Community
  • 1
  • 1
Rn222
  • 2,167
  • 2
  • 20
  • 36

1 Answers1

0

If you look at the first solution you linked to you will notice the following line

UIBarButtonItem *barButton= [[[UIBarButtonItem alloc] initWithCustomView:chatButton] autorelease];

You can initialize a button with whatever view you would like. You can make a button with any (acceptable) view inside it.

eg.

// GRAPHICAL BUTTON FRAMEWORK
     UIButton* btton = [UIButton buttonWithType:UIButtonTypeCustom];
     [btton setFrame:CGRectMake(0, 0, 30, 30)];
     [btton addTarget:self action:@selector(SOMEROUTINE) forControlEvents:UIControlEventTouchUpInside];
     [btton setImage:[UIImage imageNamed:@"SOME IMAGE"] forState:UIControlStateNormal];
     UIBarButtonItem* remix = [[[UIBarButtonItem alloc] initWithCustomView:btton] autorelease];

Hope that helps!

rinzler
  • 236
  • 1
  • 4