gpt4 book ai didi

c++ - Qt Quick 2 iOS 缺口回避

转载 作者:太空宇宙 更新时间:2023-11-04 12:38:01 32 4
gpt4 key购买 nike

我的应用程序是全屏的。

在使用 QT Quick 2 时,如何避免在带有缺口的 iOS 设备上将项目放在缺口和主线后面?

我的应用程序在有和没有缺口的设备上运行,我试图避免在没有缺口的设备的顶部和底部出现空白区域。

最佳答案

如果其他人遇到同样的问题。

首先让您的应用在 iOS 上不是全屏,这会在您的应用的顶部和底部创建黑色区域。

您可以更改黑色区域的颜色以更好地适合您的应用:

notch.h

#ifndef NOTCH_H
#define NOTCH_H

#include <QObject>

class Notch : public QObject{
Q_OBJECT
public:
Notch();
};

#endif

notch.mm

#include <UIKit/UIKit.h>
#include "notch.h"

Notch::Notch()
{
//Top
UIView *statusBar = (UIView *)[[UIApplication sharedApplication] valueForKey:@"statusBar"];
statusBar.backgroundColor = [UIColor colorWithRed:0.09 green:0.14 blue:0.19 alpha:1.0];

//Bottom
UIApplication *app = [UIApplication sharedApplication];
app.windows.firstObject.backgroundColor = [UIColor whiteColor];
}

现在只需调用 Notch();在你的 main.cpp 文件中

关于c++ - Qt Quick 2 iOS 缺口回避,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55537619/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com