BFIntroduceToolView.swift 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // BFIntroduceToolView.swift
  3. // BFRecordScreenKit
  4. //
  5. // Created by 胡志强 on 2021/11/26.
  6. //
  7. import Foundation
  8. import UIKit
  9. class BFIntroduceToolView: UIView {
  10. var choosedToolHandle:((UIView) -> Void)?
  11. fileprivate let toolImgs = ["", "", ""]
  12. required init?(coder: NSCoder) {
  13. fatalError("init(coder:) has not been implemented")
  14. }
  15. override init(frame: CGRect) {
  16. super.init(frame: CGRect(x: 0, y: 0, width: 40, height: 40*toolImgs.count))
  17. isUserInteractionEnabled = true
  18. clipsToBounds = true
  19. for i in 0 ..< toolImgs.count {
  20. let btn = UIButton(frame: CGRect(x: 0, y: i * 40, width: 40, height: 40))
  21. btn.backgroundColor = UIColor.randomColor()
  22. btn.setTitle("\(i)", for: .normal)
  23. btn.setImage(imageInRecordScreenKit(by: toolImgs[i]), for: .normal)
  24. btn.addTarget(self, action: #selector(toolAction(btn:)), for: .touchUpInside)
  25. addSubview(btn)
  26. }
  27. }
  28. @objc func toolAction(btn:UIButton) {
  29. let v = UILabel(frame: CGRect(x: 0, y: 0, width: 10, height: 40))
  30. v.backgroundColor = UIColor.white
  31. v.layer.shadowColor = UIColor.black.cgColor
  32. v.layer.shadowRadius = 3
  33. choosedToolHandle?(v)
  34. }
  35. }