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

修改授权页背景为透明色

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

复制代码
-(void)login
{
    //创建一个Ui配置对象
    SVSDKHyUIConfigure * Ui = [SVSDKHyUIConfigure new];
    Ui.currentViewController = self;

    //需要注意的是:要想将授权页设置为透明色需要设置modalPresentationStyle为UIModalPresentationOverFullScreen
    Ui.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
{
    //授权页view
    UIView * 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
{
    //授权页view
    UIView * 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;

    //后面代码可以自己作处理

    ```
}
相关推荐
大熊猫侯佩2 天前
在肖申克监狱玩转 iOS 26:安迪的 Liquid Glass 复仇计划
ios·swiftui·swift
非专业程序员2 天前
逆向分析CoreText中的字体级联/Font Fallback机制
前端·ios
青草地溪水旁2 天前
第十六章:固本培元,守正出奇——Template Method的模板艺术
命令模式
库奇噜啦呼2 天前
【iOS】简单的四则运算
macos·ios·cocoa
white-persist3 天前
【burp手机真机抓包】Burp Suite 在真机(Android and IOS)抓包手机APP + 微信小程序详细教程
android·前端·ios·智能手机·微信小程序·小程序·原型模式
恋猫de小郭3 天前
Fluttercon EU 2025 :Let‘s go far with Flutter
android·开发语言·flutter·ios·golang
2501_915909064 天前
iOS 抓包工具有哪些?实战对比、场景分工与开发者排查流程
android·开发语言·ios·小程序·uni-app·php·iphone
bkspiderx4 天前
C++设计模式之行为型模式:命令模式(Command)
c++·设计模式·命令模式
2501_915918415 天前
iOS 框架全解析,原生框架与跨平台框架对比、开发应用打包与 App Store 上架实战经验
android·ios·小程序·https·uni-app·iphone·webview
感谢地心引力5 天前
iOS26 打开开发者模式
windows·macos·ios·iphone·ios26