ios怎么让图片只有左半边圆角?


    let rightTopL = UILabel()
        rightTopL.text = "可开始"
        rightTopL.textAlignment = .center
//        rightTopL.layer.cornerRadius = 3
//        rightTopL.layer.masksToBounds = true

        rightTopL.font = UIFont.systemFont(ofSize: 14)
        rightTopL.textColor = UIColor.white
        rightTopL.backgroundColor = UIColor.colorWithHexString(Color_Value: "508cee", alpha: 1)
        addSubview(rightTopL)
//        rightTopL.snp.makeConstraints { (make) in
//
//            make.top.equalTo(self).offset(19)
//            make.right.equalTo(self).offset(-20)
//            make.width.equalTo(54)
//            make.height.equalTo(23)
//
//
//        }
        
        rightTopL.frame = CGRect(x:screenWidth - 73, y:24, width:54,height : 24)
        let   corner  :UIRectCorner = UIRectCorner(rawValue: UIRectCorner.RawValue(UInt8(UIRectCorner.topLeft.rawValue) |  UInt8(UIRectCorner.bottomLeft.rawValue)));//这只圆角位置
        let  path = UIBezierPath.init(roundedRect: rightTopL.bounds, byRoundingCorners: corner, cornerRadii: CGSize(width:5,height:5))
        let masklayer = CAShapeLayer()
        masklayer.frame = rightTopL.bounds;
        masklayer.path = path.cgPath;//设置路径
        rightTopL.layer.mask = masklayer

你可能感兴趣的:(ios怎么让图片只有左半边圆角?)