美文网首页IOS知识整理
iOS中设置右侧导航栏按钮

iOS中设置右侧导航栏按钮

作者: Youthfulless | 来源:发表于2017-01-09 13:58 被阅读701次

#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中设置右侧导航栏按钮

    本文链接:https://www.haomeiwen.com/subject/cmqhbttx.html