您的位置:首页 > 产品设计 > UI/UE

Snail—UI学习之工具栏UIToolBar

2015-08-10 14:14 603 查看
#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





                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: