导航栏按钮

UIButton *informationCardBtn = [UIButton buttonWithType:UIButtonTypeCustom];

[informationCardBtn addTarget:self action:@selector(SaveBtnClick) forControlEvents:UIControlEventTouchUpInside];

[informationCardBtn setImage:[UIImage imageNamed:@"保存0"] forState:UIControlStateNormal];

[informationCardBtn sizeToFit];

UIBarButtonItem *informationCardItem = [[UIBarButtonItem alloc] initWithCustomView:informationCardBtn];

UIBarButtonItem *fixedSpaceBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

fixedSpaceBarButtonItem.width = 22;

UIButton *settingBtn = [UIButton buttonWithType:UIButtonTypeCustom];

[settingBtn addTarget:self action:@selector(ModifyBtnClick) forControlEvents:UIControlEventTouchUpInside];

[settingBtn setImage:[UIImage imageNamed:@"修改0"] forState:UIControlStateNormal];

[settingBtn sizeToFit];

UIBarButtonItem *settingBtnItem = [[UIBarButtonItem alloc] initWithCustomView:settingBtn];

self.navigationItem.rightBarButtonItems  = @[informationCardItem,fixedSpaceBarButtonItem,settingBtnItem];



一个按钮



UIButton *submitBtn=[UIButton buttonWithType:UIButtonTypeCustom];

submitBtn.backgroundColor=[UIColor colorWithRed:253/255.0 green:126/255.0 blue:49/255.0 alpha:1];

submitBtn.frame=CGRectMake( 0, 0, 50, 30);

[submitBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

[submitBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];

//    [submitBtn setTitle:@"提交" forState:UIControlStateNormal];

submitBtn.layer.masksToBounds=YES;

submitBtn.layer.cornerRadius=5;

[submitBtn addTarget:self action:@selector(warmingClick) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem * rightBar = [[UIBarButtonItem alloc]initWithCustomView:submitBtn];

self.navigationItem.rightBarButtonItem = rightBar;

你可能感兴趣的:(导航栏按钮)