update
This commit is contained in:
@@ -148,7 +148,25 @@ export default class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**适配背景图
|
||||
* @method node 背景图节点
|
||||
* @param mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
*/
|
||||
public static adjustBgPixelRatioToSize(windowSize:Size,node:Node, mod:number = 1) {
|
||||
//let windowSize = view.getVisibleSize();
|
||||
let bgTf = node.getComponent(UITransform)
|
||||
if (bgTf) {
|
||||
if (mod == 1 && bgTf.height < windowSize.height) {
|
||||
let scale = windowSize.height / bgTf.height
|
||||
bgTf.height = bgTf.height * scale
|
||||
bgTf.width = bgTf.width * scale
|
||||
} else if (mod == 2 && bgTf.width < windowSize.width) {
|
||||
let scale = windowSize.width / bgTf.width
|
||||
bgTf.height = bgTf.height * scale
|
||||
bgTf.width = bgTf.width * scale
|
||||
}
|
||||
}
|
||||
}
|
||||
/**适配背景图
|
||||
* @method node 背景图节点
|
||||
* @param mod 适配模式 1=按高度适配 2=按宽度适配
|
||||
@@ -157,6 +175,15 @@ export default class Utils {
|
||||
let windowSize = view.getVisibleSize();
|
||||
let bgTf = node.getComponent(UITransform)
|
||||
if (bgTf) {
|
||||
if(mod == 3)
|
||||
{
|
||||
if(windowSize.height-bgTf.height < windowSize.width-bgTf.width )
|
||||
{
|
||||
mod = 1;
|
||||
}else{
|
||||
mod = 2;
|
||||
}
|
||||
}
|
||||
if (mod == 1 && bgTf.height < windowSize.height) {
|
||||
let scale = windowSize.height / bgTf.height
|
||||
bgTf.height = bgTf.height * scale
|
||||
|
||||
Reference in New Issue
Block a user