不知道为什么textinput一直没有垂直居中的属性.于是就自己写了个类,支持垂直居中 :
package com.sandy.global.view.component.textinput
...{
import mx.controls.Text;
import mx.controls.TextInput;
public class VerticalMiddleTextInput extends TextInput
...{
public function VerticalMiddleTextInput()
...{
super()
}
override protected function createChildren():void
...{
super.createChildren();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
...{
super.updateDisplayList( unscaledWidth, unscaledHeight );
this.textField.height = this.textField.textHeight ;
this.textField.y = this.height/2 -this.textField.height/2
}
}
}
本文介绍了一个自定义的Flex组件VerticalMiddleTextInput,该组件继承自TextInput并实现了文本的垂直居中显示。通过覆盖默认的行为,确保了文本无论在何种高度下都能保持良好的视觉效果。
1591

被折叠的 条评论
为什么被折叠?



