美文网首页iOS开发iOS开发
iOS遮罩GKCoverSwift(GKCover,swift版

iOS遮罩GKCoverSwift(GKCover,swift版

作者: QuintGao | 来源:发表于2017-05-02 15:02 被阅读156次

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版

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