In Xcode 6 Beta 4 stroking with SKShapeNode doesn&

2019-05-06 23:51发布

问题:

In Xcode 6 beta 2 it worked fine, but in beta 4 it doesn't work anymore. Does anyone know what's behind this mystery?

let circle = SKShapeNode(circleOfRadius: 125);
circle.strokeColor = UIColor(red: 255, green: 255, blue: 255, alpha: 1.0);
circle.lineWidth = 4
self.addChild(circle);

In beta 4 nothing can be seen.

Thanks for your help in advance.

回答1:

This is a common issue with Xcode 6 Beta 4 when using the simulator. It renders fine when using an actual device. See this developer forums thread. It is worth noting that the issue is exclusive to stroking in that setting circle.fillColor still fills the circle (or whatever your SKShapeNode is drawing) correctly.

Also keep in mind that when initializing a UIColor with RGB values the RGB values must be between (inclusive) 0.0 and 1.0.

circle.strokeColor = UIColor(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0);

Or alternatively use the preset:

circle.strokeColor = UIColor.whiteColor()