ImageCodeViewController.swift 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // ImageCodeViewController.swift
  3. // MTP2_iOS
  4. //
  5. // Created by Handy_Cao on 2020/3/24.
  6. // Copyright © 2020 Muchinfo. All rights reserved.
  7. //
  8. import UIKit
  9. /// 滑动图形动态验证码视图容器控制类
  10. class ImageCodeViewController: BaseViewController {
  11. // MARK: - 属性列表
  12. @IBOutlet weak var bgView: UIView! {
  13. didSet {
  14. bgView.layer.cornerRadius = 5.0
  15. bgView.layer.masksToBounds = true
  16. }
  17. }
  18. /// 图形验证码
  19. @IBOutlet weak var imageCodeView: UIView! {
  20. didSet {
  21. let imageString = String(format: "codeimage%ld", String.randomInRange(range: 1..<8))
  22. 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
  23. if isSuccess {
  24. self.dismiss(animated: true) {
  25. /// 执行回调
  26. if self.popBlock != nil { self.popBlock!("") }
  27. }
  28. }
  29. }
  30. imageCodeView.addSubview(codeView)
  31. }
  32. }
  33. /// 定义block
  34. typealias block = (_ String: String) ->()
  35. /// 创建block变量
  36. var popBlock: block?
  37. // MARK: - 生命周期相关
  38. override func viewDidLoad() {
  39. super.viewDidLoad()
  40. // Do any additional setup after loading the view.
  41. /// UI界面初始化
  42. buildView()
  43. }
  44. // MARK: - 初始化相关
  45. /// UI界面初始化
  46. private func buildView() {
  47. }
  48. /*
  49. // MARK: - Navigation
  50. // In a storyboard-based application, you will often want to do a little preparation before navigation
  51. override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  52. // Get the new view controller using segue.destination.
  53. // Pass the selected object to the new view controller.
  54. }
  55. */
  56. }