iOS遮罩GKCoverSwift(GKCover,swift版本)

github地址:GKCoverSwift

使用方法:

        // 1.创建要显示的视图,并设置大小
        let topImage = UIImage(named: "top1")
        let imageView = UIImageView(image: topImage)
        imageView.gk_size = CGSize(width: kScreenW, height: kScreenW * (topImage?.size.height)! / (topImage?.size.width)!)
        
        let v = UIView()
        v.frame = CGRect(x: 0, y: 64, width: kScreenW, height: kScreenH - 64)
        v.backgroundColor = UIColor.clear
        view.addSubview(v)
        
        // 2. 创建遮罩,并设置显示方式
        let cover = GKCover(fromView: v, contentView: imageView, style: .Translucent, showStyle: .Top, showAnimStyle: .Top, hideAnimStyle: .Top, notClick: false, showBlock: { 
            
        }) { 
            v .removeFromSuperview()
        }

        // 3. 显示
        cover.show()

具体demo详见github里面的demo。

第一次写swift,希望多多支持!

你可能感兴趣的:(iOS遮罩GKCoverSwift(GKCover,swift版本))