各个安卓手机和苹果手机的物理尺寸都不一样:
譬如苹果X:414*896
苹果SE: 375*667
安卓手机像素就更多了,三星小米等等,物理像素都是不一样的
那么ui出图的时候,是不是每款手机都要有对应的像素呢?
那肯定是不用的,正常来说,针对微信小程序开发的ui,宽度750像素即可
对应h5和app开发的,宽度为1080像素
至于高度,跟宽度保存16:9,内容不能撑满整个屏幕,就做整个尺寸
/**
* 1080尺寸转px
* @param {Number} no
*/
export const calculatedSize = no => {
let rem = window['lib']['flexible'].rem;
let rootValue = 108;
no = Number(no);
return no > 2 ? (rem / rootValue * no).toFixed(2) : no;
}
/**
* 1080尺寸转rem
* @param {Number} no
*/
export const px2rem = no => {
let rem = window['lib']['flexible'].rem;
let rootValue = 108;
no = Number(no);
return window['lib']['flexible'].px2rem(no > 2 ? (rem / rootValue * no) : no)
};
为了凑个字数,我把代码贴出来了,当然,我知道也没有人会看,只是为了证明,你只管出1080px的图,剩下的交给前端。
现在产品用来做交互的墨刀软件也可以出ui,不需要前端自己裁图,非常方便,感兴趣的要学习一下哦,logo贴在下面
,