我能夠解決這個由於@InvalidMemory的評論和@ mike663的答案。基本上,您可以按照包含標籤的矩形比例縮放標籤。
func adjustLabelFontSizeToFitRect(labelNode:SKLabelNode, rect:CGRect) {
// Determine the font scaling factor that should let the label text fit in the given rectangle.
let scalingFactor = min(rect.width/labelNode.frame.width, rect.height/labelNode.frame.height)
// Change the fontSize.
labelNode.fontSize *= scalingFactor
// Optionally move the SKLabelNode to the center of the rectangle.
labelNode.position = CGPoint(x: rect.midX, y: rect.midY - labelNode.frame.height/2.0)
}
這裏是鏈接到other question。
這個類似的問題應該可以幫到你我認爲>> http://stackoverflow.com/q/30980918 –