github地址:GKCoverSwift
使用方法:
// 1.創(chuàng)建要顯示的視圖码耐,并設置大小
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. 創(chuàng)建遮罩,并設置顯示方式
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筋粗,希望多多支持!