是一条显示 上面可以放一些东西 如UiBarButtonItem
首先创建两个 UIBarButtonItem
UIBarButtonItem *mybb1 = [[UIBarButtonItem alloc]initWithTitle:@"MYBB1" style:UIBarButtonItemStylePlain target:self action:@selector(item1Action)];
UIBarButtonItem *mybb2 = [[UIBarButtonItem alloc]initWithTitle:@"MYBB1" style:UIBarButtonItemStylePlain target:self action:@selector(item2Action)];
再创建一个UIBarbuttonItem的Label
UILabel *mytblabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
mytblabel.text = @"title";
UIBarButtonItem *mybarLabel = [[UIBarButtonItem alloc]initWithCustomView:mytblabel];
然后创建UIToolbar 并把三个Item加到toolbar里
NSArray *myItems = [NSArray arrayWithObjects:mybb1,mybb2,mybarLabel,nil];
UIToolbar *myDemoToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 200, self.view.bounds.size.width, 40)];
myDemoToolBar.barStyle = UIBarStyleBlack;
myDemoToolBar.alpha = 0.3;
myDemoToolBar.items = myItems;
[self.view addSubview:myDemoToolBar];
接下来再实现两个selector,一个显示UIAlertView,一个显示UIActionSheet
- (void) item1Action{
UIAlertView *myAlertView = [[UIAlertView alloc]initWithTitle:@"标题" message:@"继续" delegate:self cancelButtonTitle:@"false" otherButtonTitles:@"yes", nil];
[myAlertView show];
}
- (void) item2Action{
UIActionSheet *myActionSheet = [[UIActionSheet alloc]initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancle" destructiveButtonTitle:@"yes" otherButtonTitles:@"go on",@"pause", nil];
[myActionSheet showInView:self.view];
}