canvas 设置参数无效

我在代码 onLoad 里面设置了fitHeight和fitWidth 没效果,之前1.8.2是可以的

var canvas = this.node.getComponent(cc.Canvas);
var size = cc.view.getVisibleSize();
var scale = size.height /size.width;
if(scale > 16/9){
canvas.fitWidth = true;
canvas.fitWidth = true;
}

打到答案了 适配没问题,但是由于你手动更改了适配模式之后没有立即更新 Canvas 尺寸,导致 widget 计算时还是基于旧的尺寸来计算的。

在你的 Resolution 组件的 onLoad 函数最后,添加 canvas.alignWithScreen() 就可以了