第一种 使用系统提供的方法,具体直接看代码
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"取消" style:UIBarButtonItemStylePlain target:self action:@selector(cancleAction)];
//自定义保存按钮
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc] initWithTitle:@"保存" style:UIBarButtonItemStyleDone target:self action:@selector(submitAction)];
第二种 使用自定义控件的方式
UIButton *btu=[UIButton buttonWithType:UIButtonTypeCustom];
// [btu setTitle:@"取消" forState:UIControlStateNormal];
// [btu setTintColor:[UIColor whiteColor]];
// btu.titleLabel.font=[UIFont systemFontOfSize:15.0];
// [btu addTarget:self action:@selector(cancleAction) forControlEvents:UIControlEventTouchUpInside];
// //自定义返回按钮
// UIBarButtonItem *backBtu=[[UIBarButtonItem alloc] initWithCustomView:btu];
// self.navigationItem.leftBarButtonItems=@[backBtu];