Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用UIBezierPath:byRoundingCorners:Swift 2和Swift 3_Ios_Swift_Uibezierpath_Rounded Corners - Fatal编程技术网

Ios 使用UIBezierPath:byRoundingCorners:Swift 2和Swift 3

Ios 使用UIBezierPath:byRoundingCorners:Swift 2和Swift 3,ios,swift,uibezierpath,rounded-corners,Ios,Swift,Uibezierpath,Rounded Corners,我用这个代码使一个按钮的两个角变圆 let buttonPath = UIBezierPath(roundedRect: button.bounds, byRoundingCorners: .TopLeft | .BottomLeft, cornerRadii: CGSizeMake(1.0, 1.0)) 它抛出一个错误: 二进制运算符“|”不能应用于两个UIRecentC

我用这个代码使一个按钮的两个角变圆

let buttonPath = UIBezierPath(roundedRect: button.bounds,
                              byRoundingCorners: .TopLeft | .BottomLeft, 
                              cornerRadii: CGSizeMake(1.0, 1.0))
它抛出一个错误:

二进制运算符“|”不能应用于两个UIRecentCorner操作数


如何在Swift 2.0中使用此方法?

Swift 2:

let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                              byRoundingCorners: [.TopLeft , .BottomLeft], 
                              cornerRadii: CGSizeMake(1.0, 1.0))
let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                              byRoundingCorners: [.topLeft ,.bottomLeft], 
                              cornerRadii: CGSize(width:1.0, height:1.0))
Swift 3和Swift 4:

let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                              byRoundingCorners: [.TopLeft , .BottomLeft], 
                              cornerRadii: CGSizeMake(1.0, 1.0))
let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                              byRoundingCorners: [.topLeft ,.bottomLeft], 
                              cornerRadii: CGSize(width:1.0, height:1.0))

在这种情况下,swift 2.0中需要使两个角接合。F.例如:

let corners = UIRectCorner.TopLeft.union(UIRectCorner.BottomLeft)
let buttonPath = UIBezierPath(roundedRect: button.bounds, 
                              byRoundingCorners: corners,
                              cornerRadii: CGSizeMake(1.0, 1.0))
与Swift 2和Swift 3配合使用