Use a UIView instead of a UIButton that contains a UIToolbar with UIBarButtonItems.
UIView *buttonContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 80, 44)]; buttonContainer.backgroundColor = [UIColor clearColor]; UIToolbar *dummyBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 80, 44)]; UIBarButtonItem *b1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(doSomething:)]; UIBarButtonItem *b2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(doSomething:)]; NSArray *items = [[NSArray alloc] initWithObjects:b1, b2, nil]; [dummyBar setItems:items]; [buttonContainer addSubview:dummyBar]; ... -(void)doSomething:(id)sender { NSLog(@"Button pushed"); }
Jared price
source share