HuiYanOsConfig.languageType 配置:枚举值 | 含义 |
HY_DEFAULT | 跟随系统设置(默认) |
HY_CUSTOMIZE_LANGUAGE | 自定义语言 |
HuiYanOsConfig *config = [[HuiYanOsConfig alloc] init];config.languageType = HY_DEFAULT;
demo/ 目录下的工程文件,找到 UserLanguageBundle 目录下的 Localizable,该部分为翻译源文件。
UserLanguageBundle 构建目标(Build Target)。
ar.lproj)。
Localizable.strings。
Localizable 中找到新增的多语言文件,并对内容进行翻译:
// 左侧为 SDK 使用的 Key,右侧为目标语言翻译内容"Verifi_OK" = "OK";"Verifi_exit" = "Exit";// ... 其余 Key 见交付包内 Localizable 文件
UserLanguageBundle.bundle。
Info.plist 和 _CodeSignature 文件夹。UserLanguageBundle.bundle 导入宿主工程。HuiYanOsConfig *config = [[HuiYanOsConfig alloc] init];// 1. 启用自定义语言模式config.languageType = HY_CUSTOMIZE_LANGUAGE;// 2. 指定 Bundle 的绝对路径config.languageBundlePath = [[NSBundle mainBundle] pathForResource:@"UserLanguageBundle" ofType:@"bundle"];// 3. 指定语言文件夹名称config.userLanguageFileName = @"ja.lproj";
属性 | 类型 | 必填条件 | 说明 |
languageType | 枚举 | 必填 | 设为 HY_CUSTOMIZE_LANGUAGE 才启用自定义 |
languageBundlePath | NSString * | 使用自定义语言时必填 | UserLanguageBundle 的绝对路径 |
userLanguageFileName | NSString * | 使用自定义语言时必填 | 目标 .lproj 文件夹名,如 ja.lproj |
languageBundlePath 为 nil,SDK 将从 mainBundle 中查找多语言资源(默认行为)。HuiYanOsConfig *config = [[HuiYanOsConfig alloc] init];// 设置出现操作错误时提示文本的颜色config.feedBackErrorColor = 0xFF584C;// 设置操作正确时提示文本的颜色config.feedBackTxtColor = 0xFF0000;// 设置出现操作错误时圆形框的颜色config.authCircleErrorColor = 0xFF584C;// 当动作正确时设置圆形框的颜色config.authCircleCorrectColor = 0x29CC85;// 设置识别页面背景颜色config.authLayoutBgColor = 0xFFFFFF;// 设置提示文本字体和大小config.feedBackTxtFont = [UIFont systemFontOfSize:18];// 设置其他提示文本字体和大小config.feedbackExtraTxtFont = [UIFont systemFontOfSize:18];// 设置倒计时文字颜色config.countDownTxtColor = 0xFFFFFF;// 设置取消按钮文字颜色config.cancelTxtColor = 0xFFFFFF;// 设置是否显示内部对话框,默认为 YESconfig.isShowDialog = YES;// 设置隐藏核身头像引导框,默认为 NOconfig.isHideAvatarGuideFrame = NO;
HuiYanOsConfig.delegate 可监听 SDK 界面的创建与销毁事件,在核身页面显示时插入自定义控件:HuiYanOsConfig *config = [[HuiYanOsConfig alloc] init];config.delegate = self; // 实现 HuiYanOverseasDelegate 协议
// HuiYanOverseasDelegate 协议方法@protocol HuiYanOverseasDelegate <NSObject>@required/// 核身主界面显示时回调,authView 为 SDK 展示的根视图- (void)onMainViewCreate:(UIView *)authView;@optional/// 核身界面被移除时回调- (void)onMainViewDestroy;@end
@interface ViewController ()<HuiYanOverseasDelegate>@end@implementation ViewController- (void)onMainViewCreate:(UIView *)authView {UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 200, 30)];label.backgroundColor = [UIColor blackColor];label.textColor = [UIColor yellowColor];label.text = @"Custom Label";label.font = [UIFont systemFontOfSize:16];label.textAlignment = NSTextAlignmentCenter;[authView addSubview:label];}- (void)onMainViewDestroy {NSLog(@"huiyan face vc destroy");}@end
控件名称 | 控件描述 | tag 值 |
cancelButton | 活体核身页面取消/返回按钮 | 101 |
timeoutLabel | 活体核身页面倒计时标签 | 102 |
tipsLabel | 活体核身页面提示文字 | 103 |
fakeNavBarView | 活体核身页面虚拟导航栏 | 200 |
onMainViewCreate: 回调,可在核身页面创建后直接通过 viewWithTag: 获取以上控件并进行修改。- (void)onMainViewCreate:(UIView *)authView {// 修改取消按钮图标UIButton *cancelButton = (UIButton *)[authView viewWithTag:101];UIImage *backImage = [UIImage systemImageNamed:@"chevron.left"];[cancelButton setImage:backImage forState:UIControlStateNormal];// 修改取消按钮的 leading 左边距约束for (NSLayoutConstraint *constraint in cancelButton.superview.constraints) {if ((constraint.firstItem == cancelButton && constraint.firstAttribute == NSLayoutAttributeLeading) ||(constraint.secondItem == cancelButton && constraint.secondAttribute == NSLayoutAttributeLeading)) {constraint.constant = 16.0;break;}}// 修改倒计时标签颜色和字体UILabel *timeoutLabel = (UILabel *)[authView viewWithTag:102];timeoutLabel.textColor = [UIColor whiteColor];timeoutLabel.font = [UIFont systemFontOfSize:15];// 修改虚拟导航栏背景颜色UIView *navBarView = [authView viewWithTag:200];navBarView.backgroundColor = [UIColor colorWithRed:0.05 green:0.05 blue:0.1 alpha:1.0];// 在虚拟导航栏上增加自定义标题CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;CGRect frame = CGRectMake(0, statusBarHeight, navBarView.bounds.size.width, navBarView.bounds.size.height - statusBarHeight);UILabel *titleLabel = [[UILabel alloc] initWithFrame:frame];titleLabel.text = @"Custom Title";titleLabel.textColor = [UIColor whiteColor];titleLabel.textAlignment = NSTextAlignmentCenter;[navBarView addSubview:titleLabel];}
if (view) { ... }),防止控件不存在时引发崩溃。feedBackErrorColor)与回调中的控件修改可以同时使用,回调中的修改将覆盖对应控件的最终效果。UserUIBundle 构建目标下:demo/└── UserUIBundle/└── TXYOsAuthingViewController.xib # 活体核身主页面
XIB 文件名 | 对应页面 | 说明 |
TXYOsAuthingViewController | 活体核身主页面 | 活体检测与人脸比对的主界面 |


demo/ 目录下的工程文件。UserUIBundle 构建目标(Build Target)。TXYOsAuthingViewController.xib 的布局约束,或新增控件。UserUIBundle.bundle。Info.plist 和 _CodeSignature 文件夹。UserUIBundle.bundle 导入宿主工程。HuiYanOsConfig *config = [[HuiYanOsConfig alloc] init];// 指定 HuiYanSDKUI Bundle 的绝对路径(必填)config.huiyanSdkUIBundlePath = [[NSBundle mainBundle] pathForResource:@"HuiYanSDKUI" ofType:@"bundle"];// 指定自定义 UI Bundle 的绝对路径config.userUIBundlePath = [[NSBundle mainBundle] pathForResource:@"UserUIBundle" ofType:@"bundle"];
demo/UserUIBundle/ 整个目录拷贝到宿主工程的代码仓库中,作为自定义 UI 的源码目录,后续所有修改均在此目录进行,便于随项目一起版本管理。HuiYanOsConfig *config = [[HuiYanOsConfig alloc] init];config.authLicense = [[NSBundle mainBundle] pathForResource:@"license" ofType:@""];// --- 自定义 UI ---// Bundle 路径(必填)config.huiyanSdkUIBundlePath = [[NSBundle mainBundle] pathForResource:@"HuiYanSDKUI" ofType:@"bundle"];config.faceTrackerBundlePath = [[NSBundle mainBundle] pathForResource:@"face-tracker-v003" ofType:@"bundle"];// 自定义 UI Bundle(可选)config.userUIBundlePath = [[NSBundle mainBundle] pathForResource:@"UserUIBundle" ofType:@"bundle"];// 代码级样式微调(可选)config.feedBackErrorColor = 0xFF584C;config.authCircleCorrectColor = 0x29CC85;// 实现 delegate 监听 UI 事件(可选)config.delegate = self;// --- 自定义多语言 ---config.languageType = HY_CUSTOMIZE_LANGUAGE;config.languageBundlePath = [[NSBundle mainBundle] pathForResource:@"UserLanguageBundle" ofType:@"bundle"];config.userLanguageFileName = @"ja.lproj";// 启动核身[[HuiYanOSKit sharedInstance] startHuiYaneKYC:@"your-face-token"withConfig:configwithSuccessCallback:^(HuiYanOsAuthResult *authResult, id reserved) {// 核身成功,使用 authResult.faceToken 查询结果} withFailCallback:^(int errCode, NSString *errMsg, id reserved) {// 核身失败,错误码 HY_BUNDLE_CONFIGURATION_EXCEPTION(307) 表示 Bundle 路径配置异常}];
failCallback 返回以下错误码:错误码 | 枚举 | 触发条件 |
307 | HY_BUNDLE_CONFIGURATION_EXCEPTION | 某个 Bundle 路径不存在或不合法 |
errMsg)示例:"HuiYanSDKUI bundle path is not found":huiyanSdkUIBundlePath 指向的路径不存在"face-tracker-v003 bundle path is not found":faceTrackerBundlePath 指向的路径不存在"user bundle is invalid":userUIBundlePath 指向的路径不存在"user language bundle is not found":languageBundlePath 指向的路径不存在旧字段 | 新字段 | 变更说明 |
userUIBundleName | userUIBundlePath | 由 Bundle 名称改为绝对路径 |
userLanguageBundleName | languageBundlePath | 由 Bundle 名称改为绝对路径 |
// 旧写法(v1.0.9.10 及以下)config.userUIBundleName = @"UserUIBundle";config.userLanguageBundleName = @"UserLanguageBundle";// 新写法(v1.0.9.11 及以上)config.userUIBundlePath = [[NSBundle mainBundle] pathForResource:@"UserUIBundle" ofType:@"bundle"];config.languageBundlePath = [[NSBundle mainBundle] pathForResource:@"UserLanguageBundle" ofType:@"bundle"];
nil,SDK 保持与旧版本相同的默认行为(从 mainBundle 中查找对应 Bundle),不影响未使用自定义功能的接入方。文档反馈