Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSMutableArray* buttons = [[[NSMutableArray alloc] initWithCapacity:3] autorelease];
- UIButton * button1 = [UIButton buttonWithType:UIButtonTypeCustom];
- [button1 setFrame:CGRectMake(0.0f, 0.0f, 25.0f, 25.0f)];
- [button1 addTarget:self action:@selector(firstMethod:) forControlEvents:UIControlEventTouchUpInside];
- [button1 setImage:[UIImage imageNamed:@"first-button.png"] forState:UIControlStateNormal];
- UIBarButtonItem * buttonItem1 = [[UIBarButtonItem alloc] initWithCustomView:button1];
- [buttons addObject:buttonItem1];
- UIButton * button2 = [UIButton buttonWithType:UIButtonTypeCustom];
- [button2 setFrame:CGRectMake(0.0f, 0.0f, 25.0f, 25.0f)];
- [button2 addTarget:self action:@selector(secondMethod:) forControlEvents:UIControlEventTouchUpInside];
- [button2 setImage:[UIImage imageNamed:@"second-button.png"] forState:UIControlStateNormal];
- UIBarButtonItem * buttonItem2 = [[UIBarButtonItem alloc] initWithCustomView:button2];
- [buttons addObject:buttonItem2];
- float barWidth = button1.frame.size.width + button2.frame.size.width;
- UIToolbar* tbar = [[[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, barWidth * 1.5, 44.01)] autorelease];
- [tbar setItems:buttons];
- UIImage *imgBack = [UIImage imageNamed:@"image-back.png"];
- UIImageView *tbarBg = [[[UIImageView alloc] initWithImage: imgBack] autorelease];
- tbarBg.backgroundColor = [UIColor redColor];
- [tbar insertSubview:tbarBg atIndex:tbar.subviews.count == 0 ? 0 : 1];
- self.navigationController.navigationBar.topItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tbar];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement