一:
// UIButton *editSome; 为全局变量,已开启ARC; editSome = [UIButton buttonWithType:UIButtonTypeCustom]; editSome.frame = kCCR(0, 0, 45, 25); [editSome setTitle:@"编辑" forState:UIControlStateNormal]; [editSome setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; editSome.titleLabel.font = [UIFont fontWithName:@"Verdana-Bold" size:13]; [editSome setBackgroundImage:[UIImage imageNamed:@"navBarRightIMG.png"] forState:UIControlStateNormal]; [editSome addTarget:self action:@selector(editButtonItemChange) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *editSomes = [[UIBarButtonItem alloc]initWithCustomView:editSome]; self.navigationItem.rightBarButtonItem = editSomes;
二:
-(void)editButtonItemChange { static BOOL isTure = YES; if (isTure) { [editSome setTitle:@"完成" forState:UIControlStateNormal]; } else { [editSome setTitle:@"编辑" forState:UIControlStateNormal]; } [collectedListTableVC setEditing:isTure animated:YES]; [super setEditing:isTure animated:YES]; isTure = !isTure; }