本文介绍了swift 2 sprite-kit中的多行标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在swift 2 sprite-kit中为游戏制作多行标签。文本需要环绕而不是离开屏幕。贝娄是我的,但我不知道该怎么做

I need to be able to make a multi-line label in swift 2 sprite-kit for a game. The text needs to wrap around rather than go off of the screen. Bellow is what I have but I do not know what to do

import Foundation
import UIKit
import SpriteKit

class JDQuotes: SKLabelNode {

    var number = 0

    init(num: Int) {
        super.init()

        if num == 1 {

            text = "\"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. laborum.\""

        }
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}


推荐答案

启动iOS 11后,最终可以使用 SKLabelNode

Starting iOS 11, this finally becomes possible with SKLabelNode:

    let lb = SKLabelNode(fontNamed: "Copperplate")
    lb.text = "Put your long text here..."
    lb.numberOfLines = 0
    lb.preferredMaxLayoutWidth = 1000

这篇关于swift 2 sprite-kit中的多行标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 08:37