let view = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
view.backgroundColor = UIColor.red
let path1 = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 100, height: 100), byRoundingCorners: .topLeft, cornerRadii: CGSize(width: 45, height: 10))
let path2 = UIBezierPath(roundedRect: CGRect(x: 100, y: 0, width: 100, height: 100), byRoundingCorners: .topRight, cornerRadii: CGSize(width: 20, height: 20))
let path3 = UIBezierPath(roundedRect: CGRect(x: 0, y: 100, width: 100, height: 100), byRoundingCorners: .bottomLeft, cornerRadii: CGSize(width: 30, height: 30))
let path4 = UIBezierPath(roundedRect: CGRect(x: 100, y: 100, width: 100, height: 100), byRoundingCorners: .bottomRight, cornerRadii: CGSize(width: 40, height: 40))
path1.append(path2)
path1.append(path3)
path1.append(path4)
let shape = CAShapeLayer()
shape.path = path1.cgPath
view.layer.mask = shape
效果圖