// // ImageCodeViewController.swift // MTP2_iOS // // Created by Handy_Cao on 2020/3/24. // Copyright © 2020 Muchinfo. All rights reserved. // import UIKit /// 滑动图形动态验证码视图容器控制类 class ImageCodeViewController: BaseViewController { // MARK: - 属性列表 @IBOutlet weak var bgView: UIView! { didSet { bgView.layer.cornerRadius = 5.0 bgView.layer.masksToBounds = true } } /// 图形验证码 @IBOutlet weak var imageCodeView: UIView! { didSet { let imageString = String(format: "codeimage%ld", String.randomInRange(range: 1..<8)) let codeView = WMZCodeView.shareInstance().add(with: CodeType.image, withImageName: imageString, witgFrame: CGRect(origin: CGPoint.zero, size: CGSize(width: UIScreen.main.bounds.size.width*0.85, height: imageCodeView.frame.size.height))) { (isSuccess) in if isSuccess { self.dismiss(animated: true) { /// 执行回调 if self.popBlock != nil { self.popBlock!("") } } } } imageCodeView.addSubview(codeView) } } /// 定义block typealias block = (_ String: String) ->() /// 创建block变量 var popBlock: block? // MARK: - 生命周期相关 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view. /// UI界面初始化 buildView() } // MARK: - 初始化相关 /// UI界面初始化 private func buildView() { } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ }