如何在导航栏的右上角加两个item

如何在导航栏的右上角加两个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_第1张图片




一个item的情况

UIBarButtonItem*rightBarItem = [[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"header_partook"]style:UIBarButtonItemStylePlaintarget:selfaction:@selector(shardBtn)];

self.navigationItem.rightBarButtonItem= rightBarItem;

你可能感兴趣的:(如何在导航栏的右上角加两个item)