Taking and sharing Screenshot using Swift in SpriteKit
<p>I just made a simple game using Swift in SpriteKit. At the end scene, it shows Score, Share and Restart button.</p>

<p>The function for sharing screenshot of the end scene is still pending. I found a very simple solution here, <a href="https://www.frispgames.com/sharing-a-screenshot-on-ios-using-swift-and-sprite-kit/" rel="nofollow">https://www.frispgames.com/sharing-a-screenshot-on-ios-using-swift-and-sprite-kit/</a></p>

<p>I'm not a pro, therefore all my attempts so far to implement this solution is in vain. </p>

<p>I'm trying to call <code>shareScore()</code> function (as written in that solution) when the player taps <code>shareButton()</code> but it isn't working.</p>

<p>Here's my code for the EndScene</p>

<pre><code>var restartBtn = SKSpriteNode()
var shareBtn = SKSpriteNode()
var scoreLbl = SKLabelNode()
var score = Int()


override func didMoveToView(view: SKView) {

    scene!.scaleMode = .AspectFill

    self.view?.backgroundColor = UIColor.grayColor()

    scoreLabel()

    shareBtn = SKSpriteNode(imageNamed: "Share")
    shareBtn.position = CGPointMake(self.frame.width / 2, self.frame.height / 3)
    shareBtn.setScale(0.0005)
    self.addChild(shareBtn)

    restartBtn = SKSpriteNode(imageNamed: "Restart")
    restartBtn.position = CGPointMake(self.frame.width / 2, self.frame.height / 4)
    restartBtn.setScale(0.0005)

    self.addChild(restartBtn)
}


func scoreLabel() {

    let scoreDefault = NSUserDefaults.standardUserDefaults()
    score = scoreDefault.valueForKey("score") as! NSInteger

    scoreLbl.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2)
    scoreLbl.fontSize = 40
    scoreLbl.setScale(0.001)
    scoreLbl.text = "Score: \(score)"

    self.addChild(scoreLbl)
}


override func touchesBegan(touches: Set&lt;UITouch&gt;, withEvent event: UIEvent?) {

    for touch in touches {

        let location = touch.locationInNode(self)

        if restartBtn.containsPoint(location) {

            let gameScene = GameScene(fileNamed: "GameScene")
            let transition = SKTransition.fadeWithDuration(0.5)
            let skView = self.view! as SKView
            skView.ignoresSiblingOrder = true
            gameScene?.scaleMode = .AspectFill
            skView.presentScene(gameScene!, transition: transition)

        } else if shareBtn.containsPoint(location) {

            // Function for sharing screenshot should be called here
        }
    }

}
</code></pre>