1. 方案一
最简单的办法,就是让UI根据屏幕出各种尺寸的图,直接拿来用
2.方案二
UIBezierPath绘制 + 图片
实现思路: 1.创建个充满屏幕的全透明View 【GuideView】
2.创建个背景view 【bgView】,放置在GuideView上
3.开始绘制透明框等,设置bgview
4.放置图片
示例代码【重点BSLPath方法】
import UIKit
class KWGuide1View: KWView {
override func kw_setupViews() {
super.kw_setupViews()
frame = CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight)
backgroundColor = .clear
self.BSLPath()
}
override func kw_setupLayouts() {
super.kw_setupLayouts()
}
func BSLPath() {
let bgView = UIView(frame: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
addSubview(bgView)
//整个背景
let bsl = UIBezierPath.init(rect: CGRect(x: 0, y: 0, width: KScreenWidth, height: KScreenHeight))
//透明框
let bslClear = UIBezierPath(roundedRect: CGRect(x: KScreenWidth/4*3, y: KScreenHeight-KTabBarHeight-KHomeIndicatorHeight+KHomeIndicatorHeight, width: KScreenWidth/4, height: KTabBarHeight-KHomeIndicatorHeight),cornerRadius:5).reversing()
bsl.append(bslClear)
let layer = CAShapeLayer()
layer.fillColor = UIColor.init(r: 0, g: 0, b: 0, alpha: 0.7).cgColor
layer.path = bsl.cgPath
bgView.layer.addSublayer(layer)
addSubview(imgv)
imgv.snp.makeConstraints { make in
make.size.equalTo(CGSize(width: KScreenWidth-50, height: (KScreenWidth-50)/336*487 ))
make.right.equalTo(-15)
make.bottom.equalTo(-KTabBarHeight)
}
bgView.kw.tapAtion { _ in
self.removeFromSuperview()
let v2 = KWGuide2View()
UIApplication.shared.keyWindow?.addSubview(v2)
}
}
private lazy var imgv:UIImageView = {
let img = UIImageView()
img.image = UIImage(named: "ic_yindao_1")
img.contentMode = .scaleToFill
return img
}()
}