extension UIView {
/**
* @param corners: 哪一个角
* TopLeft
* TopRight
* BottomLeft
* BottomRight
* AllCorners
* @param radius:弧度
*/
func cutCornersWithPosition(corners: UIRectCorner, radius: Float) -> Void {
let maskPath = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: CGFloat(radius), height: CGFloat(radius)))
let maskLayer = CAShapeLayer()
maskLayer.frame = self.bounds
maskLayer.path = maskPath.CGPath
self.layer.mask = maskLayer
}
}