一些网上的方法设置无效:
第一种:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker
animated:YES
completion:^(void){
UIViewController * vc = controller.viewControllers.lastObject;
UIBarButtonItem * cancelBtn = [vc valueForKey:@"imagePickerCancelButton"];
UIButton * button = [cancelBtn valueForKey:@"view"];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}];
第二种:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker. navigationController.navigationBar.tintColor = [UIColor blackColor];
picker. navigationController.navigationBar.topItem.rightBarButtonItem.tintColor = [UIColor whiteColor];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
最后尝试有效方法:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
picker.navigationBar.tintColor = [UIColor redColor];
picker.navigationBar.barStyle = UIBarStyleBlackOpaque;
picker.navigationBar.topItem.rightBarButtonItem.tintColor = [UIColor blackColor];