12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- //
- // ADHAlertView.swift
- // ADHTuanCan
- //
- // Created by 敖德亨 on 2023/10/31.
- //
- import UIKit
- class ADHAlertView: UIView {
- @IBOutlet weak var blackView: UIView!
- var sureActionBlock : (()->Void)?
-
- override func awakeFromNib() {
- super.awakeFromNib()
-
- }
-
- public func show(){
- kAppDelegateWindow.addSubview(self)
- self.blackView.alpha = 0
- self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- UIView.animate(withDuration: 0.5) {
- self.frame = CGRect.init(x: 0, y: 0, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- self.layoutIfNeeded()
- }
- DELAY(0.5) {
- self.blackView.alpha = 0.3
- }
- }
- /// 隐藏
- public func hidden(){
- self.blackView.alpha = 0
- UIView.animate(withDuration: 0.5) {
- self.frame = CGRect.init(x: 0, y: kSCREEN_HEIGHT, width: kSCREEN_WIDTH, height: kSCREEN_HEIGHT)
- self.layoutIfNeeded()
- }
- DELAY(0.5) {
- self.removeFromSuperview()
- }
- }
-
- @IBAction func cancelAction(_ sender: UIButton) {
- self.hidden()
- }
-
- @IBAction func sureAction(_ sender: UIButton) {
- if self.sureActionBlock != nil{
- self.sureActionBlock!()
- }
- self.hidden()
- }
-
- }
|