当前位置: 首页>编程语言>正文

ios UIImagePickerController "取消"自定义颜色问题

一些网上的方法设置无效:
第一种:
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];


https://www.xamrdz.com/lan/5dt1995236.html

相关文章: