2018-12-17
2018-12-17 本文已影响2人
谁拿浮生伴我一世流年
swift 4.0 设置 UIView 圆角
funcsetView() ->UIView{
let view =UIView()
let path:UIBezierPath=UIBezierPath.init(roundedRect: view.bounds, byRoundingCorners: [.topLeft,.topRight], cornerRadii:CGSize(width:12, height:0))
let shapLayer:CAShapeLayer = CAShapeLayer()
shapLayer.lineWidth=1
shapLayer.strokeColor = UIColor.white.cgColor
shapLayer.fillColor = UIColor.clear.cgColor
shapLayer.path = path.cgPath
let maskLayer:CAShapeLayer = CAShapeLayer.init()
maskLayer.path= path.cgPath
view.layer.mask= maskLayer
view.layer.addSublayer(shapLayer)
return view
}