Ios 格式化UIImagePickerController的文本';s";取消“;及;选择「;按钮
我想格式化(更改字体类型和大小)Ios 格式化UIImagePickerController的文本';s";取消“;及;选择「;按钮,ios,objective-c,Ios,Objective C,我想格式化(更改字体类型和大小)Cancel的占位符文本和UIImagePickerController中的Choose按钮。我检查了几个问题,但找不到相关的答案,可以作为一个良好的起点。已经检查过苹果的PhotoPicker示例,但是对于这个目的来说太复杂了,我需要一些轻量级的东西来编辑字体 这是我的图像选择器代码: if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhot
Cancel
的占位符文本和UIImagePickerController
中的Choose
按钮。我检查了几个问题,但找不到相关的答案,可以作为一个良好的起点。已经检查过苹果的PhotoPicker示例,但是对于这个目的来说太复杂了,我需要一些轻量级的东西来编辑字体
这是我的图像选择器代码:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary] == YES) {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = self;
imagePicker.allowsEditing = YES;
// this line does nothing
imagePicker.navigationBar.tintColor = [UIColor redColor];
[self presentViewController:imagePicker animated:YES completion:nil];
[self.tableView reloadData];
}
您可以为此使用
ui外观
代理:
[[UIBarButtonItem appearanceWhenContainedIn:[UIImagePickerController class], nil] setTitleTextAttributes:@{ NSFontAttributeName : [UIFont fontWithName:@"AmericanTypewriter" size:14.0] } forState:UIControlStateNormal];
将
UIImagePickerController中条形按钮的字体更改为AmericanTypewriter
大小14。如果不想使用外观代理(即,如果只想为一个控制器设置外观代理),还可以在显示特定控制器之前修改其项目:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated {
NSMutableArray *items = [NSMutableArray array];
[items addObjectsFromArray:viewController.navigationItem.leftBarButtonItems];
[items addObjectsFromArray:viewController.navigationItem.rightBarButtonItems];
NSDictionary *font = @{NSFontAttributeName: [UIFont fontWithName:@"Trebuchet MS" size:16]};
for (UIBarButtonItem *item in items) {
[item setTitleTextAttributes:font forState:UIControlStateNormal];
}
}
我希望这可能会对您有所帮助。因为UIImagePickerController
是一种导航控制器,您也将自己设置为UINavigationController
代理。然后:
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//Write your code here for setting the color
}
我该怎么称呼这个?在viewDidLoad
中,或者在出现选择器之前的任何时间,我在哪里配置选择器?@vv88。它是应用程序范围的,所以在应用程序代理中包含外观代理是很常见的。我想我的问题有点不正确,我想到了底部的“选择和取消”按钮,在那里你可以放大选中的图像。这不是picker视图吗?不同iOS版本的picker略有不同,但我认为您指的是拍照确认屏幕。你能添加一个屏幕截图来确定吗?@Rivera你说得对,我指的是拍照确认屏幕。我相信是图像采集器。。
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
//Write your code here for setting the color
}