自定义UIBarButtonItem
//单个自定义按钮
UIButton *button =[UIButtonbuttonWithType:UIButtonTypeCustom];
button.frame =CGRectMake(0, 0, 50, 50);
UIBarButtonItem\*Button = \[\[UIBarButtonItemalloc\] initWithCustomView:button\];
self.navigationItem.leftBarButtonItem = Button;
//多个按钮
UIBarButtonItem \*btn = \[\[UIBarButtonItemalloc\] initWithBarButtonSystemItem:UIBarButtonSystemItemPlaytarget:selfaction:@selector(click:)\];
UIBarButtonItem btnOne = \[\[UIBarButtonItemalloc\] initWithBarButtonSystemItem:UIBarButtonSystemItemPausetarget:selfaction:@selector(click1:)\];
\[self.navigationItemsetRightBarButtonItems:\[NSArrayarrayWithObjects:btn,btnOne,nil\]\];
//自定义View上随意放置button
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(kWidth * 4 / 5, 0, 75, 30)];
//分享按钮
UIButton \*sharebutton = \[UIButton buttonWithType:(UIButtonTypeCustom)\];
sharebutton.frame = CGRectMake(5, 0, 30, 30);
\[view addSubview:sharebutton\];
//收藏按钮
self.collectbutton = \[UIButton buttonWithType:(UIButtonTypeCustom)\];
self.collectbutton.frame = CGRectMake(45, 0, 30, 30);
\[view addSubview:self.collectbutton\];
UIBarButtonItem \*collectItem = \[\[UIBarButtonItem alloc\] initWithCustomView:view\];
self.navigationItem.rightBarButtonItem = collectItem;
还没有评论,来说两句吧...