SKLabelNode + NSMutableAttributedString =无阴影

时间:2018-03-20 03:30:14

标签: swift sprite-kit nsattributedstring nsmutableattributedstring sklabelnode

    let paragraph = NSMutableParagraphStyle()
    paragraph.alignment = NSTextAlignment.right
    paragraph.tailIndent = -3
    let shadow = NSShadow()
    shadow.shadowBlurRadius = 5
    shadow.shadowColor = UIColor.gray
    shadow.shadowOffset = CGSize(width: 2, height: -2)
    let text = NSMutableAttributedString(string: "MY LABEL", attributes:
   [NSShadowAttributeName : shadow,
    NSStrokeColorAttributeName : UIColor.black,
    NSStrokeWidthAttributeName : -3,
    NSForegroundColorAttributeName: UIColor.white,
    NSFontAttributeName : UIFont(name: "MyFont", size: 24) as Any,
    NSParagraphStyleAttributeName : paragraph])

    let node = SKLabelNode()
    addChild(node)
    node.attributedText = attributedString

它有效,但没有阴影。我可以在众所周知的NSMutableAttributedString上使用相同的ASAttributedLabel,但效果很好并且有阴影,但我想使用SKLabelNodeIOS11上获得更好的效果。 ASAttributedLabel可能会滞后于动态场景:(

0 个答案:

没有答案