ADHAlertView.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // ADHAlertView.swift
  3. // ADHTuanCan
  4. //
  5. // Created by 敖德亨 on 2023/10/31.
  6. //
  7. import UIKit
  8. class ADHAlertView: UIView {
  9. @IBOutlet weak var blackView: UIView!
  10. var sureActionBlock : (()->Void)?
  11. override func awakeFromNib() {
  12. super.awakeFromNib()
  13. }
  14. public func show(){
  15. kAppDelegateWindow.addSubview(self)
  16. self.blackView.alpha = 0
  17. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  18. UIView.animate(withDuration: 0.5) {
  19. self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  20. self.layoutIfNeeded()
  21. }
  22. DELAY(0.5) {
  23. self.blackView.alpha = 0.3
  24. }
  25. }
  26. /// 隐藏
  27. public func hidden(){
  28. self.blackView.alpha = 0
  29. UIView.animate(withDuration: 0.5) {
  30. self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
  31. self.layoutIfNeeded()
  32. }
  33. DELAY(0.5) {
  34. self.removeFromSuperview()
  35. }
  36. }
  37. @IBAction func cancelAction(_ sender: UIButton) {
  38. self.hidden()
  39. }
  40. @IBAction func sureAction(_ sender: UIButton) {
  41. if self.sureActionBlock != nil{
  42. self.sureActionBlock!()
  43. }
  44. self.hidden()
  45. }
  46. }