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)
        }
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容