解决方法
如果使用导航控制器,则可以使用自定义按钮并隐藏后退按钮.
要隐藏后退按钮使用此:
self.navigationItem.hidesBackButton = YES;
而对于自定义按钮:
UIButton * customButton = [UIButton buttonWithType:UIButtonTypeCustom]; [customButton setBackgroundColor:[UIColor colorWithRed:197.0/255.0 green:190.0/255.0 blue:157.0/255.0 alpha:1.0]]; [customButton setTitle:@"Do Something" forState:UIControlStateNormal]; customButton.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:11.0f]; [customButton.layer setCornerRadius:3.0f]; [customButton.layer setMasksToBounds:YES]; [customButton.layer setBorderWidth:1.0f]; [customButton.layer setBorderColor: [[UIColor grayColor] CGColor]]; customButton.frame=CGRectMake(0.0,100.0,50.0,25.0); [customButton addTarget:self action:@selector(customMethod:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem * customItem = [[UIBarButtonItem alloc] initWithCustomView:customButton]; customItem.tintColor=[UIColor blackColor]; self.navigationItem.leftBarButtonItem = customItem;
这对你有用.快乐的编码