如何在导航栏的右上角加两个item
@property(nonatomic,strong)UIButton*anotherButton;
@property(nonatomic,strong)UIButton*anotherButton2;
-(void)viewDidLoad的方法下写UIBarButtonSystemItem
UIBarButtonItem*anotherButton = [[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"header_partook"]style:UIBarButtonItemStylePlaintarget:selfaction:@selector(shardBtn:)];
UIBarButtonItem*anotherButton2 = [[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"header_keep"]style:UIBarButtonItemStylePlaintarget:selfaction:@selector(did:)];
[self.navigationItemsetRightBarButtonItems:[NSArrayarrayWithObjects: anotherButton,anotherButton2,nil]];
-(void)shardBtn:(UIButton*)btn{
NSLog(@"---shardBtn---");
}
-(void)did:(UIButton*)btn{
NSLog(@"---did---");
}
效果图:
一个item的情况
UIBarButtonItem*rightBarItem = [[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"header_partook"]style:UIBarButtonItemStylePlaintarget:selfaction:@selector(shardBtn)];
self.navigationItem.rightBarButtonItem= rightBarItem;