swift window

swift window 弹窗可触控弹框外面的内容


Simulator Screen Shot - iPhone 12 - 2021-12-18 at 14.45.28.png

popUpView用自定义 的view代替

func showWindow() {
//        let window = UIApplication.shared.keyWindow!
//        window.addSubview(popUpView)
        let delegate  = UIApplication.shared.delegate as! AppDelegate
        let popUpView = PopUpWindowView(frame: CGRect(x: 24, y: -280, width: kScreenWidth-48, height: 280))
        popUpView.tag = 99
        delegate.window?.addSubview(popUpView)
        popUpView.clickCloseBlock = {
            print("关闭,移除窗口")
            delegate.window?.viewWithTag(99)?.removeFromSuperview()
        }
        popUpView.clickChatBlock = {
            print("聊天,移除窗口")
            delegate.window?.viewWithTag(99)?.removeFromSuperview()
        }
        //弹出动画
        UIView.animate(withDuration: 0.5, delay: 0.1, usingSpringWithDamping: 0.2, initialSpringVelocity: 10, options: [.curveEaseInOut]) {
            popUpView.frame = CGRect(x: 24, y: 80, width: kScreenWidth-48, height: 280)
        } completion: { isComplete in
            print(isComplete)
        }
    }

你可能感兴趣的:(swift window)