秒验 iOS端授权页添加自定义按钮

如何添加自定义控件
基于一键登录的拉起授权页面功能,如果想要在我们的授权页面中添加自定义组件,例如使用其他方式登录的按钮,来实现其他方式登录功能,为用户呈现更多选择登录的方式。本文介绍如何在一键登录授权界面中实现添加自定义控件功能,实现方式如下:

//自定义授权页面
-(void)setupAuthPageCustomStyle:(UIViewController *)authVC userInfo:(SVSDKHyProtocolUserInfo *)userInfo
{
    //授权页view
    UIView * authPageView = authVC.view;

    //中间可以对原有授权页上的按钮文字等作自定义操作

    ```

    //***添加自定义控件****
    // 自定义返回按钮
    UIButton *customBackButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [customBackButton setImage:[UIImage imageNamed:@"fh"] forState:UIControlStateNormal];
    [customBackButton setTitle:@"返回" forState:UIControlStateNormal];
    [customBackButton setTitleColor:[UIColor colorWithRed:35/255.0 green:35/255.0 blue:38/255.0 alpha:1/1.0] forState:UIControlStateNormal];
    customBackButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Regular" size:18];
    [customBackButton addTarget:self.target action:@selector(customBackAction:) forControlEvents:UIControlEventTouchUpInside];
    [authPageView addSubview:customBackButton];

    UIView *bottomView = [[UIView alloc] init];
    [authPageView addSubview:bottomView];

    UILabel *mLbl = [[UILabel alloc] init];
    mLbl.textAlignment = NSTextAlignmentCenter;
    mLbl.font = [UIFont fontWithName:@"PingFangSC-Regular" size:13];
    mLbl.textColor = [UIColor colorWithRed:184/255.0 green:184/255.0 blue:188/255.0 alpha:1/1.0];
    mLbl.text = @"其他方式登录";
    [mLbl sizeToFit];

    [bottomView addSubview:mLbl];

    UIButton *wxBtn = [[UIButton alloc] init];
    [wxBtn setBackgroundImage:[UIImage imageNamed:@"wc"] forState:UIControlStateNormal];
    [wxBtn addTarget:self.target action:@selector(weixinLoginAction:) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:wxBtn];

    UIButton *zhBtn = [[UIButton alloc] init];
    [zhBtn setBackgroundImage:[UIImage imageNamed:@"zh"] forState:UIControlStateNormal];
    [zhBtn addTarget:self.target action:@selector(usernameLoginAction:) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:zhBtn];

    //布局(可以进行竖屏和横屏的布局):自定义控件和授权页基本控件可以放一起统一布局即可

    ```
    //自定义控件布局(这里使用的是第三方布局控件Masonry)
    [customBackButton mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(50);
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(15);
    }];

    // bottomView
    [bottomView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(privacyTextView.mas_top);
        make.centerX.mas_equalTo(0);
        make.width.mas_equalTo(SVD_ScreenWidth);
        make.height.mas_equalTo(70+mLbl.bounds.size.height);
    }];

    [mLbl mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(wxBtn.mas_top).offset(-10);
        make.centerX.mas_equalTo(0);
    }];

    [wxBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-10);
        make.centerX.mas_equalTo(-50);
        make.width.height.mas_equalTo(48);
    }];

    [zhBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(wxBtn);
        make.centerX.mas_equalTo(50);
        make.width.height.mas_equalTo(48);
    }];

}

相关推荐

  1. iOS授权添加定义按钮

    2024-07-09 22:46:09       20 阅读
  2. iOS如何修改授权背景

    2024-07-09 22:46:09       23 阅读
  3. 若依分离版 后定义

    2024-07-09 22:46:09       19 阅读
  4. 定义 按钮间,按钮边框滑动。

    2024-07-09 22:46:09       55 阅读
  5. iOS 按钮添加点击震动

    2024-07-09 22:46:09       46 阅读
  6. 使用Python合并PDF文件并添加定义目录及

    2024-07-09 22:46:09       217 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-09 22:46:09       50 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-09 22:46:09       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-09 22:46:09       43 阅读
  4. Python语言-面向对象

    2024-07-09 22:46:09       54 阅读

热门阅读

  1. 代码随想录算法训练营:23/60

    2024-07-09 22:46:09       20 阅读
  2. Android Camera API发展历程

    2024-07-09 22:46:09       18 阅读
  3. 工作日常学习记录

    2024-07-09 22:46:09       20 阅读
  4. ELK的储存、分析功能介绍!

    2024-07-09 22:46:09       22 阅读
  5. Linux实战记录

    2024-07-09 22:46:09       21 阅读
  6. 价值投资者什么时候卖出股票?

    2024-07-09 22:46:09       20 阅读
  7. 【大模型】小样本学习:解锁微调LLM的潜力

    2024-07-09 22:46:09       23 阅读
  8. 大数据处理系统架构特征

    2024-07-09 22:46:09       20 阅读
  9. 应用程序提权

    2024-07-09 22:46:09       23 阅读