/ / Top Cantos arredondados no nó - kit rápido, sprite

Top Cantos arredondados no nó - swift-kit rápido

Eu tenho um nó retangular:

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)

Como adiciono um raio de borda de 20 somente aos cantos TopLeft e TopRight?

Respostas:

3 para resposta № 1

Usuário este UIBezierPath inicializador:

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

e especifique [.TopLeft, .TopRight] para o byRoundingCorners argumento.

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