登录/注册- 滑动拼图验证码(IOS/Swift)

news/2024/10/18 5:52:15/

本章介绍如何使用ios开发出滑动拼图验证码,分别OC代码和swift代码调用

1.导入项目model文件OC代码(下载完整Demo)
在这里插入图片描述

2.放入你需要显示的图片
在这里插入图片描述

一:OC调用

#import "ViewController.h"
#import "CodeView.h"@interface ViewController () <CodeViewDelegate>
@property (nonatomic, strong) CodeView * codeView;
@end@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib._codeView = [[CodeView alloc]initWithFrame:self.view.frame];[self.view addSubview:_codeView];_codeView.delegate = self;_codeView.passDistance = 2;self.view.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:0.8];
}- (void)codeViewAuthenticationResult:(BOOL)result
{NSLog(@"验证%@通过", result ? @"" : @"不");
}- (void)viewWillAppear:(BOOL)animated
{[super viewWillAppear:animated];[_codeView setCodeImage:[UIImage imageNamed:@"testB.jpg"]];
}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated.
}@end

swift_52">二:swift调用

import UIKitclass MeViewController: BaseViewController,CodeViewDelegate{private var codeView = CodeView()private let meView = MeView()override func initData() {// 显示自定义视图弹窗showCustomPopup()}// 显示自定义视图弹窗func showCustomPopup() {// 实例化自定义视图codeView = CodeView(frame: CGRect(x: 0, y: 0, width: ALERTVIEW_WIDTH - 150, height: ALERTVIEW_HEIGHT))// 设置自定义视图的样式和内容// 添加到当前视图控制器的视图上//let customView = CodeView(frame: self.view.frame)
//            self.view.addSubview(codeView)codeView.delegate = selfcodeView.passDistance = 2// 设置自定义视图的布局约束,可以根据需要进行调整codeView.center = self.view.centercodeView.setCodeImage(UIImage(named: "testA.jpg"))meView.addSubview(codeView)// 添加点击背景关闭弹窗的逻辑(可选)let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissCustomPopup))codeView.addGestureRecognizer(tapGesture)}// 点击背景关闭弹窗的逻辑(可选)@objc func dismissCustomPopup() {// 移除自定义视图self.view.subviews.forEach { subview inif subview is CodeView {subview.removeFromSuperview()}}}func codeViewAuthenticationResult(_ result: Bool) {print("code%@ == ",result)}
}

http://www.ppmy.cn/news/1469494.html

相关文章

MySQL 日志(二)

本篇将继续介绍MySQL日志的相关内容 目录 一、二进制日志 简介 注意事项 删除二进制日志 查看二进制日志 二进制日志的格式 二、服务器日志维护 一、二进制日志 简介 二进制日志中主要记录了MySQL的更改事件&#xff08;不包含SELECT和SHOW),例如&#xff1a;表的…

模型 WOOP

说明&#xff1a;系列文章 分享 模型&#xff0c;了解更多&#x1f449; 模型_思维模型目录。不再拖延和懒惰&#xff0c;让梦想照进现实。 1 WOOP模型的应用 1.1 WOOP模型提高自己健身习惯 如果你想要养成健身的习惯&#xff0c;那么使用WOOP模型来提高自己健身习惯&#xf…

1.xshell传不了文件输出0000如何解决.....2.k8s中metalLB文件内容

xshell传不了文件输出0000如何解决 centos版本 1,因为没有工具下载即可 yum -y install lrzszk8s中metalLB文件内容 2.metalLB文件内容 cat metallb-native.yaml apiVersion: v1 kind: Namespace metadata:labels:pod-security.kubernetes.io/audit: privilegedpod-securit…

PROSAIL模型前向模拟与植被参数遥感

原文链接&#xff1a;PROSAIL模型前向模拟与植被参数遥感 “绿水青山就是金山银山”的生态文明理念现已深入人心&#xff0c;从顶层设计到全面部署&#xff0c;生态文明建设进入举措最实、推进最快、力度最大、成效最好的时期。生态文明评价必须将生态系统健康作为基本内容&am…

方法分享 |公网IP怎么指定非433端口实现https访问

公网IP可以通过指定非443端口实现HTTPS访问。在网络配置中&#xff0c;虽然HTTPS协议默认使用443端口&#xff0c;但没有规定不能在其他端口上实施HTTPS服务。使用非标准端口进行HTTPS通信需要正确配置服务器和SSL证书&#xff0c;并确保客户端能够连接到指定的端口。下面说明如…

【DevOps】 什么是容器 - 一种全新的软件部署方式

目录 引言 一、什么是容器 二、容器的工作原理 三、容器的主要特性 四、容器技术带来的变革 五、容器技术的主要应用场景 六、容器技术的主要挑战 七、容器技术的发展趋势 引言 在过去的几十年里,软件行业经历了飞速的发展。从最初的大型机时代,到后来的个人电脑时代,…

stm32MP135裸机编程:修改基于SD卡的FSBL-A用户程序引导程序(boot)

0 参考资料 轻松使用STM32MP13x - 如MCU般在cortex A核上裸跑应用程序.pdf stm32mp135官方开发板原理图&#xff08;mb1635-bdp-v1-0.zip&#xff09; STM32Cube_FW_MP13_V1.0.0 STM32CubeIDE v1.15 1 为什么需要修改FSBL-A用户程序引导程序 FSBL-A用户程序引导程序的作用在《…

java值jsp语法笔记

1 JSP注释 1.1 显示注释 显示注释会出现在生成的HTML文档中&#xff0c;对用户可见。 <!-- 这是一个HTML显示注释 --> 1.2 隐式注释 隐式注释不会出现在生成的HTML文档中&#xff0c;对用户不可见。 <%-- 这是一个JSP隐式注释 --%> 2 JSP脚本元素 2.1 局部…