How to draw a hollow circle with two different colors?

Solutions Collect From Internet About “How to draw a hollow circle with two different colors?”

You can try using SKCropNode, this allows you to show only half of each circle. See below code for example of this.

class GameScene: SKScene {
override func didMoveToView(view: SKView) {

    anchorPoint = CGPointMake(0.5, 0.5)

    // Half Circle #1

    let myCrop1 = SKCropNode()

    let myMask1 = SKSpriteNode(color: UIColor.blackColor(), size: CGSizeMake(100, 100))
    myMask1.position.y = -50

    let circle1 = SKShapeNode(circleOfRadius: 50)
    circle1.lineWidth = 0
    circle1.fillColor = UIColor.blueColor()

    myCrop1.addChild(circle1)
    myCrop1.maskNode = myMask1
    addChild(myCrop1)

    // Half Circle #2

    let myCrop2 = SKCropNode()

    let myMask2 = SKSpriteNode(color: UIColor.blackColor(), size: CGSizeMake(100, 100))
    myMask2.position.y = 50

    let circle2 = SKShapeNode(circleOfRadius: 50)
    circle2.lineWidth = 0
    circle2.fillColor = UIColor.redColor()

    myCrop2.addChild(circle2)
    myCrop2.maskNode = myMask2
    addChild(myCrop2)


    }

}

I haven’t really used SKCropNode that much before, so I’m not sure how good my code is, but below is the result I got on my iPhone.

enter image description here

EDIT: You should be able to add a 3rd SKCropNode to make the centre of the circle transparent if required.

EDIT: Below for transparent centre

class GameScene: SKScene {
override func didMoveToView(view: SKView) {

    anchorPoint = CGPointMake(0.5, 0.5)

    let transparentCenterMask = SKShapeNode(circleOfRadius: 50)
    transparentCenterMask.lineWidth = 20
    let transparentCenterCrop = SKCropNode()
    transparentCenterCrop.maskNode = transparentCenterMask

    // Half Circle #1

    let myCrop1 = SKCropNode()

    let myMask1 = SKSpriteNode(color: UIColor.blackColor(), size: CGSizeMake(100, 100))
    myMask1.position.y = -50

    let circle1 = SKShapeNode(circleOfRadius: 50)
    circle1.lineWidth = 0
    circle1.fillColor = UIColor.blueColor()

    myCrop1.addChild(circle1)
    myCrop1.maskNode = myMask1
    transparentCenterCrop.addChild(myCrop1)

    // Half Circle #2

    let myCrop2 = SKCropNode()

    let myMask2 = SKSpriteNode(color: UIColor.blackColor(), size: CGSizeMake(100, 100))
    myMask2.position.y = 50

    let circle2 = SKShapeNode(circleOfRadius: 50)
    circle2.lineWidth = 0
    circle2.fillColor = UIColor.redColor()

    myCrop2.addChild(circle2)
    myCrop2.maskNode = myMask2
    transparentCenterCrop.addChild(myCrop2)

    addChild(transparentCenterCrop)


    }

}

enter image description here