iOS中设置右侧导航栏按钮

#pragma mark 设置右上角按钮

- (void)setupRightItem{

_rightButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 70,100, 50, 50)];

[_rightButton setTitle:@"邀请记录" forState:UIControlStateNormal];

[_rightButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

_rightButton.titleLabel.font = [UIFont systemFontOfSize:12];

[_rightButton addTarget:self action:@selector(loginInvite) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem* rightItem = [[UIBarButtonItem alloc]initWithCustomView:_rightButton];

self.navigationItem.rightBarButtonItem = rightItem;

}

#pragma mark 右上角按钮的点击方法

- (void)loginInvite

{

_rightButton.enabled = NO;

InviteVipViewController *userInviteVC = [[InviteVipViewController alloc]init];

[self.navigationController pushViewController:userInviteVC animated:YES];

}

你可能感兴趣的:(iOS中设置右侧导航栏按钮)