【发布时间】:2014-10-15 04:21:11
【问题描述】:
在下面的黄色圆圈没有显示在 IOS 模拟器中。如果我添加当前已注释掉的 setFillColor,则会得到一个红色圆圈。
为什么不显示形状的轮廓? 有没有办法触发大纲?
-(void)addTargetNode2 {
float radius=90;
SKShapeNode *targetOuter = [SKShapeNode shapeNodeWithCircleOfRadius:radius];
//[targetOuter setFillColor:[UIColor redColor]];
[targetOuter setStrokeColor:[UIColor yellowColor]];
[targetOuter setLineWidth:1];
//Position the node.
targetOuter.position = CGPointMake(CGRectGetMidX(self.frame),
CGRectGetMidY(self.frame));
[self addChild:targetOuter];
}
我确实找到了 this 文章 - 但没有答案。
编辑: 我有一个工作解决方法......但不是特别喜欢它。在一个实心圆圈的顶部绘制一个背景颜色的圆圈:
-(void)addTarget {
float radius=50;
CGFloat borderWidth=3;
//Draw the Circle.
SKShapeNode *targetOuter = [SKShapeNode shapeNodeWithCircleOfRadius:radius];
[targetOuter setName:@"targetOuter"];
[targetOuter setFillColor:[UIColor yellowColor]];
//Following line should set the outline color but isn't working.
//[targetOuter setStrokeColor:[UIColor yellowColor]];
[targetOuter setLineWidth:1];
targetOuter.position = CGPointMake(CGRectGetMidX(self.frame),
CGRectGetMidY(self.frame));
[self addChild:targetOuter];
/* Work around
Add a circle the color of the background to emulate an outline.
Can be removed in targetOuter outline works.
*/
SKShapeNode *targetInner = [SKShapeNode shapeNodeWithCircleOfRadius:radius-borderWidth];
[targetInner setFillColor:self.backgroundColor];
targetInner.position = targetOuter.position;
[self addChild:targetInner];
}
【问题讨论】: