欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 科技 > IT业 > 秒验 iOS端如何修改授权页背景

秒验 iOS端如何修改授权页背景

2024/10/24 1:48:23 来源:https://blog.csdn.net/apkkkk/article/details/140204349  浏览:    关键词:秒验 iOS端如何修改授权页背景

修改授权页背景为透明色
基于一键登录的拉起授权页功能,如果想要修改授权页的背景颜色,来调整成符合自己app样式的背景。以下代码示例主要介绍如何修改授权页的背景颜色,例如将授权页背景修改为透明色:

-(void)login
{//创建一个Ui配置对象SVSDKHyUIConfigure * Ui = [SVSDKHyUIConfigure new];Ui.currentViewController = self;//需要注意的是:要想将授权页设置为透明色需要设置modalPresentationStyle为UIModalPresentationOverFullScreenUi.modalPresentationStyle = @(UIModalPresentationOverFullScreen);//Swift
中可以设置为iConfigure.modalPresentationStyle = 5[SVSDKHyVerify setDelegate:self];[SVSDKHyVerify openAuthPageWithModel:Ui openAuthPageListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {if(error!=nil){//拉起授权页失败NSLog(@"%@",error.description);}else{//拉起授权页成功NSLog(@"成功");}} cancelAuthPageListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {//点击sdk自带返回,关闭,其他方式登录(添加的自定义关闭按钮事件不会触发此回调)NSLog(@"====%@",resultDic);NSLog(@"----%@",error.description);} oneKeyLoginListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {//一键登录点击获取token回调//关闭页面,当Ui.manualDismiss = @(YES);时需要手动调用此方法关闭// [SVSDKHyVerify hideLoading];if (error==nil) {//获取token成功,开始调用token置换手机号接口NSLog(@"%@",resultDic);Ui.manualDismiss = @(YES);[SVSDKHyVerify finishLoginVcAnimated:YES Completion:^{//                SectionViewController * view = [[SectionViewController alloc] init];//                [self presentViewController:view animated:YES completion:^{////                }];}];}else{//获取token失败,可以自定义跳转到其他界面}}];
}-(void)svVerifyAuthPageViewDidLoad:(UIViewController *)authVC userInfo:(SVSDKHyProtocolUserInfo *)userInfo
{//授权页viewUIView * authpage = authVC.view;//1.授权页背景设为透明或半透明,作为弹窗的背景蒙层authpage.backgroundColor = UIColor.clearColor;//后面代码可以自己作处理```
}

修改授权页背景为图片
基于一键登录的拉起授权页功能,如果想要修改授权页的背景图片,来调整成符合自己app样式的背景。以下代码示例主要介绍如何修改授权页的背景图片,注意最后需要将背景图层置于所有图层最底部,具体实现如下:

-(void)login
{//创建一个Ui配置对象SVSDKHyUIConfigure * Ui = [SVSDKHyUIConfigure new];Ui.currentViewController = self;[SVSDKHyVerify setDelegate:self];[SVSDKHyVerify openAuthPageWithModel:Ui openAuthPageListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {if(error!=nil){//拉起授权页失败NSLog(@"%@",error.description);}else{//拉起授权页成功NSLog(@"成功");}} cancelAuthPageListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {//点击sdk自带返回,关闭,其他方式登录(添加的自定义关闭按钮事件不会触发此回调)NSLog(@"====%@",resultDic);NSLog(@"----%@",error.description);} oneKeyLoginListener:^(NSDictionary * _Nullable resultDic, NSError * _Nullable error) {//一键登录点击获取token回调//关闭页面,当Ui.manualDismiss = @(YES);时需要手动调用此方法关闭// [SVSDKHyVerify hideLoading];if (error==nil) {//获取token成功,开始调用token置换手机号接口NSLog(@"%@",resultDic);Ui.manualDismiss = @(YES);[SVSDKHyVerify finishLoginVcAnimated:YES Completion:^{//                SectionViewController * view = [[SectionViewController alloc] init];//                [self presentViewController:view animated:YES completion:^{////                }];}];}else{//获取token失败,可以自定义跳转到其他界面}}];
}
-(void)svVerifyAuthPageViewDidLoad:(UIViewController *)authVC userInfo:(SVSDKHyProtocolUserInfo *)userInfo
{//授权页viewUIView * authpage = authVC.view;//设置背景图UIImageView * imageBg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background"]];imageBg.frame = CGRectMake(0, 0, authpage.bounds.size.width, authpage.bounds.size.height);[authpage addSubview:imageBg];UIButton * backButton = userInfo.backButton;//自带的backButton,在navBar上UIButton * loginButton = userInfo.loginButton;UIImageView * logoImageView  = userInfo.logoImageView;UILabel  * phoneLabel = userInfo.phoneLabel;UIButton * checkBox  = userInfo.checkBox;UITextView * privacyTextView = userInfo.privacyTextView;UILabel  * sloganLabel = userInfo.sloganLabel;//将背景图放置最底层imageBg.layer.zPosition = loginButton.layer.zPosition-1;//后面代码可以自己作处理```
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com