#import "WJJViewController.h"
@interface WJJViewController ()
@property (nonatomic, strong) UIToolbar * toolBar;
@end
@implementation WJJViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 100, 320, 50)];
[self.view addSubview:self.toolBar];
self.toolBar.backgroundColor = [UIColor blackColor];
//为自己的item添加一个方法
UIBarButtonItem * item1 = [[UIBarButtonItem alloc] initWithTitle:@"asds" style:UIBarButtonItemStyleBordered target:self action:@selector(item1Click:)];
//调用系统的BarButtonItem
/*
UIBarButtonSystemItemDone,
UIBarButtonSystemItemCancel,
UIBarButtonSystemItemEdit,
UIBarButtonSystemItemSave,
UIBarButtonSystemItemAdd,
UIBarButtonSystemItemFlexibleSpace,
UIBarButtonSystemItemFixedSpace,
UIBarButtonSystemItemCompose,
UIBarButtonSystemItemReply,
UIBarButtonSystemItemAction,
UIBarButtonSystemItemOrganize,
UIBarButtonSystemItemBookmarks,
UIBarButtonSystemItemSearch,
UIBarButtonSystemItemRefresh,
UIBarButtonSystemItemStop,
UIBarButtonSystemItemCamera,
UIBarButtonSystemItemTrash,
UIBarButtonSystemItemPlay,
UIBarButtonSystemItemPause,
UIBarButtonSystemItemRewind,
UIBarButtonSystemItemFastForward,
*/
UIBarButtonItem * fixSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:nil action:nil];
UIBarButtonItem * item3 = [[UIBarButtonItem alloc] initWithTitle:@"asdsda" style:UIBarButtonItemStyleBordered target:self action:@selector(item3Click:)];
self.toolBar.items = @[item1,fixSpace,item3];
}
- (void)item1Click:(id)sender{
NSLog(@"1");
}
- (void)item3Click:(id)sender{
NSLog(@"3");
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end