egretはボタンのテキストサイズを変更します

公式サイトはこんな感じ

若想要获取按钮的文本对象请使用如下方法:

var button = new eui.Button();
(<eui.Label>button.labelDisplay).size = 50;
因为labelDisplay是个接口,所以需要使用eui.Label转换。

しかし、このように書くとボタンが表示されないので
、ステージにボタンを追加してフォントを変更します。

  this.addChild(button);
        //需要在舞台添加button后再修改字体大小
        (<eui.Label>button.labelDisplay).size=40;

以下は完全なコードです

var button = new eui.Button();
        button.label = "喂薄荷糖";
        
    /
    ///
    //重要
       button.name="l"//通过这个name 下面才能判断播放哪个动画

        button.x=60;
        button.y=60;
        button.width=400;
        button.height=100;
        this.addChild(button);
        //需要在舞台添加button后再修改字体大小
        (<eui.Label>button.labelDisplay).size=40;
        button.addEventListener(egret.TouchEvent.TOUCH_TAP, bohetang, this);

おすすめ

転載: blog.csdn.net/weixin_40938312/article/details/105287636