我有一个矩形节点:
let shape = SKShapeNode()
shape.path = UIBezierPath(roundedRect: CGRect(x: -128, y: -128, width: 256, height: 256), cornerRadius: 64).CGPath
shape.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
shape.fillColor = UIColor.redColor()
shape.strokeColor = UIColor.blueColor()
shape.lineWidth = 10
addChild(shape)
如何仅向TopLeft和TopRight角添加20的边框半径?
答案 0 :(得分:3)
使用此UIBezierPath
初始化程序:
public convenience init(roundedRect rect: CGRect, byRoundingCorners corners: UIRectCorner, cornerRadii: CGSize)
并为[.TopLeft, .TopRight]
参数指定byRoundingCorners
。
shape.path = UIBezierPath(
roundedRect: CGRect(x: -128, y: -128, width: 256, height: 256),
byRoundingCorners: [.TopLeft, .TopRight]
cornerRadii: CGSize(width: 64, height: 64)).CGPath