如何编程模仿ShareThis以便通过Facebook分享内容

时间:2015-08-04 04:07:35

标签: facebook social-networking sharethis

在我的网站上,我想在每个页面上都有一个facebook图标。单击该图标应该模仿与单击ShareThis(http://www.sharethis.com/)中的Facebook图标相同的行为。

我该如何编程?

感谢任何指针和输入!

1 个答案:

答案 0 :(得分:1)

使用当前页面的位置替换下面代码中的class GameScene: SKScene { let testball = SKShapeNode(circleOfRadius: 50) let testguy = SKShapeNode(circleOfRadius: 50) let line = SKShapeNode() let pathToDraw = CGPathCreateMutable() override func didMoveToView(view: SKView) { self.backgroundColor = UIColor(colorLiteralRed: 0.9, green: 0.9, blue: 1, alpha: 0.5) testball.fillColor = UIColor.redColor() self.addChild(testball) self.testguy.position = CGPointMake(CGRectGetMinX(self.frame) + testguy.frame.width + 10, CGRectGetMinY(self.frame) + testguy.frame.height + 10) self.testguy.fillColor = SKColor.redColor() self.addChild(self.testguy) CGPathMoveToPoint(pathToDraw, nil, testguy.position.x, testguy.position.y) self.addChild(self.line) } override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) { testball.position = (touches.first?.locationInNode(self))! CGPathAddLineToPoint(pathToDraw, nil, (touches.first?.locationInNode(self).x)!, (touches.first?.locationInNode(self).y)!) self.line.path = pathToDraw self.line.strokeColor = UIColor.redColor() } override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) { testball.position = (touches.first?.locationInNode(self))! //print(touches.first?.locationInView(self.view), appendNewline: true); line.removeFromParent() testball.position = (touches.first?.locationInNode(self))! CGPathAddLineToPoint(pathToDraw, nil, (touches.first?.locationInNode(self).x)!, (touches.first?.locationInNode(self).y)!) self.line.path = pathToDraw self.line.strokeColor = UIColor.redColor() self.addChild(line) } ,并使用标题替换http://example.com/index.html(如果标题包含空格,则使用%20而不是空格)。

Title

您需要先在<a href="http://www.facebook.com/sharer/sharer.php?u=http://example.com/index.html&title=Title" target="_blank"><img src="images/fb.png" alt="Share on FB"</a> 文件夹中保存一个名为fb.png的图标,但可以免费使用信用额度链接,例如fatcow.com

source for link