在调用系统相册拍照的时候,在选择照片的时候,发现用的都是英文,效果如下:

我们想把那个Retake 和Use Photo 改为对应的汉字,先来一种最笨的方法,最后在来个高级的方法,最笨的办法当然是我们找到这两个按钮,修改他们的文字,改成我们希望的文字,这个是可以随便设置的,不叨叨 直接上代码!
方法一
在下面的代理方法找到对应的按钮
-(void)navigationController:(UINavigationController*)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated{
UIView *PLCropOverlay = [self findView:viewController.view withName:@"PLCropOverlay"];
[PLCropOverlay setValue:@"选择" forKey:@"_defaultOKButtonTitle"];
UIView *PLCropOverlayBottomBar = [self findView:PLCropOverlay withName:@"PLCropOverlayBottomBar"];
UIView *PLCropOverlayPreviewBottomBar = [self findView:PLCropOverlayBottomBar withName:@"PLCropOverlayPreviewBottomBar"];
UIButton *userButton = PLCropOverlayPreviewBottomBar.subviews.lastObject;
UIButton *cancleButton = PLCropOverlayPreviewBottomBar.subviews.firstObject;
[userButton setTitle:@"选择" forState:UIControlStateNormal];
[cancleButton setTitle:@"取消" forState:UIControlStateNormal];
}
// 通过名字找到对应的视图
-(UIView *)findView:(UIView *)aView withName:(NSString *)name {
if ([name isEqualToString:NSStringFromClass(aView.class)]){
return aView;
}
for (UIView *view in aView.subviews) {
if ([name isEqualToString:NSStringFromClass(view.class)]) {
return view;
}
}
return nil;}
其中那个userButton 和cancleButton对应那个选择按钮和取消按钮,具体要设置什么文字就看你们的产品汪了
效果如下:

方法二
如果没有特别要求,那就用系统的文字,需要在info.plist
里面填加一个key
表示app
使用系统的语言,key
为Localized resources can be mixed
设置为YES
就可以了

最终的效果如下:

网友评论