/ / Angoli arrotondati superiori sul nodo: rapido, kit sprite

In alto Angoli arrotondati sul nodo: kit rapido, sprite

Ho un nodo rettangolo:

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)

Come faccio ad aggiungere un raggio del bordo di 20 solo agli angoli TopLeft e TopRight?

risposte:

3 per risposta № 1

Utente questo UIBezierPath initializer:

public convenience init(roundedRect rect: CGRect, byRoundingCorners corners: UIRectCorner, cornerRadii: CGSize)

e specificare [.TopLeft, .TopRight] per il byRoundingCorners discussione.

shape.path = UIBezierPath(
roundedRect: CGRect(x: -128, y: -128, width: 256, height: 256),
byRoundingCorners: [.TopLeft, .TopRight]
cornerRadii: CGSize(width: 64, height: 64)).CGPath