swift 4.0 设置 UIView 圆角

 fun csetView() ->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

    }

你可能感兴趣的:(swift 4.0 设置 UIView 圆角)