美文网首页
和微信小游戏菜单按钮等高

和微信小游戏菜单按钮等高

作者: 凌迟_5339 | 来源:发表于2019-01-23 15:41 被阅读0次

    public getMenuTop(btn,type=false): void {

            let get1 = () => {

                var h2 = Main.app.mScreenHeight / 1334;

                var w = Main.app.mScreenWidth / 750;

                if (Main.app.mScreenHeight != 812) {

                    btn.y = 20 / h2 - 30 -86;

                } else if (Main.app.mScreenHeight == 812) {

                    btn.y = 94 -86;

                }

            }

            if (Main.app.mSDKVersion < '2.1.0') {

                get1()

            } else {

                if (!Main.app.mWX.menuLayout) {

                    Main.app.mWX.menuLayout = wx.getMenuButtonBoundingClientRect()

                    console.log(Main.app.mWX.menuLayout)

                }

                if (!Main.app.mWX.menuLayout || !Main.app.mWX.menuLayout.top) {

                    get1()

                } else {

                    let h = Main.app.mWX.menuLayout.height;

                    let t = Main.app.mWX.menuLayout.top;

                    let center_y = (t + h / 2) * Laya.stage.height / wxCore.uo.mPhone['screenHeight'];

                    if(!type)

                    {

                        btn.y = center_y - btn.height / 2 - 86 -( Laya.stage.height-1334)/2;

                    }

                    else

                    {

                        btn.y = center_y - 108 / 2 - 86;

                    }

                }

            }

        }

    相关文章

      网友评论

          本文标题:和微信小游戏菜单按钮等高

          本文链接:https://www.haomeiwen.com/subject/vvrjjqtx.html