h5端不勾选
但是在apk端勾选
这个要怎么搞啊???
问了ai
加了设置的方法
/**
* @en
* Dynamically set whether the node should stretch horizontally.
* This will enable both left and right alignment, causing the node to stretch.
*
* @zh
* 动态设置节点是否应水平拉伸。
* 这将同时启用左右对齐,使节点水平拉伸。
*
* @param value - Whether to enable horizontal stretching.
* @param keepSize - If true, attempt to maintain the current size by adjusting offsets.
*/
public setStretchWidth(value: boolean, keepSize = false): void {
if (value === this.isStretchWidth) {
return;
}
if (value) {
// 保存当前宽度用于尺寸保持
if (keepSize) {
const trans = this.node._uiProps.uiTransformComp!;
this._originalWidth = trans.width;
}
// 启用左右对齐
this.isAlignLeft = true;
this.isAlignRight = true;
} else {
// 禁用左右对齐中的一个或两个
if (this.isAlignLeft && this.isAlignRight) {
// 如果两者都启用,默认禁用右边对齐
this.isAlignRight = false;
}
}
this._recursiveDirty();
}
/**
* @en
* Dynamically set whether the node should stretch vertically.
* This will enable both top and bottom alignment, causing the node to stretch.
*
* @zh
* 动态设置节点是否应垂直拉伸。
* 这将同时启用上下对齐,使节点垂直拉伸。
*
* @param value - Whether to enable vertical stretching.
* @param keepSize - If true, attempt to maintain the current size by adjusting offsets.
*/
public setStretchHeight(value: boolean, keepSize = false): void {
if (value === this.isStretchHeight) {
return;
}
if (value) {
// 保存当前高度用于尺寸保持
if (keepSize) {
const trans = this.node._uiProps.uiTransformComp!;
this._originalHeight = trans.height;
}
// 启用上下对齐
this.isAlignTop = true;
this.isAlignBottom = true;
} else {
// 禁用上下对齐中的一个或两个
if (this.isAlignTop && this.isAlignBottom) {
// 如果两者都启用,默认禁用底部对齐
this.isAlignBottom = false;
}
}
this._recursiveDirty();
}