美文网首页
swift window

swift window

作者: 授之以渔不如授之以鱼 | 来源:发表于2021-12-18 14:47 被阅读0次

    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

          本文链接:https://www.haomeiwen.com/subject/cndgfrtx.html