如果只剩下 1 行,有沒有辦法將動態文本多行移動到中心,因為無法在屬性面板中調整垂直中心。
圖片 3 行文本和 1 行文本
uj5u.com熱心網友回復:
沒有默認選項,但您可以模擬它。
// Let's assume this is your TextField you need to v-align.
var TF:TextField;
// Lets also assume that TextField is still in its original place.
// Record its upper Y-coordinate and height.
var atop:Number = TF.y;
var aheight:Number = TF.height;
// These lines instruct the TextField to adjust its lower
// border so that it exactly fits the text inside.
TF.wordWrap = true;
TF.autoSize = TextFieldAutoSize.LEFT;
// Now, math time.
// The difference between original height and new (autosized) height.
var adiff:Number = aheight - TF.height;
// To vertically position the resized TextField into the center of its original
// place, you need to shift it down by half of the height difference.
// It actually works if new height is larger than original too:
// the "adiff" value will be negative and it still works out.
TF.y = atop adiff / 2;
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/417759.html
標籤:
