在Qt for ios 中,App的图标及启动画面与pc及android有所不同,在android中则是在xml中举行设置。
1) 图标 AppIcon, 必要在xcode中 “New File..” / iOS / Resource / Asset Catalog, 在Finder中找一个1024x1024的ico图标拖到如下页面,中以设置其名为 AppIcon:
在空白列表下面的 + - 按钮中 点击 “+”, 在弹出的菜单中选择: iOS / iOS App Icon
注意, 如果是要发布到store中, 此ico不能使用包含透明度的图片,所以,这里应该要上传一个四方的无透明底色的图片;
然后General / App icon and Launch Screen 中 添加 App Icon的名: AppIcon, 并将 include all app icon assets的勾打上,如下:
此时翻译后安装到apple手机上的app就显示如上的图标,而不是一个由白底网络线的空图标了;
2) 启动画面。 在android中,可以把启动画面在xml中设置,纵然按照不同的屏幕分辨率使用不同巨细的图片设置,安装在android手机上仍然是变形或偏移的,所以,最合适的方法是,在SplashScreen中加载启动图片,注意,此启动图片在加载时,必要举行缩放与裁剪,否则不同的手机显示的开机画面也是异常的,如下:
android 的 main.cpp下:
QScreen* screen = app.primaryScreen();
//!启动画面SplashScreen; 先举行裁剪;
QSize fullSize = screen->size();
QPixmap pix = QPixmap(icoDir+"/splash/fp.png");
pix = pix.scaledToWidth(fullSize.width(),Qt::SmoothTransformation);
QPixmap trimPix = pix;
if(pix.height() > fullSize.height()){
trimPix = pix.copy(0,(pix.height()-fullSize.height())/2,fullSize.width(),fullSize.height());
}
else{
pix = pix.scaledToHeight(fullSize.height(),Qt::SmoothTransformation);
trimPix = pix.copy((pix.width()-fullSize.width())/2,0,fullSize.width(),fullSize.height());
}
QSplashScreen* splashScreen = new QSplashScreen(nullptr);
splashScreen->setFixedSize(fullSize);
splashScreen->setPixmap(trimPix);
splashScreen->show();
app.processEvents();
QThread::sleep(2);
MainWindow win;
win.show();
//!关闭启动画面;
splashScreen->finish(&win);
delete splashScreen;
splashScreen = nullptr;
//-
而 ios中,必要在LaunchScreen.storyboard中举行设置,如果没有,可以新建: “New File...” / iOS / User Interface / Launch Screen , 如下:
在右侧睁开 View Controller Scene , 将Label等删除,View下只留下 Safe Area, 然后添加ImageView及相应的约束Constraints.
如下图所示:
步骤 :
a ) 先添加 启动背景图片,如上图左侧红箭头所指上面的 fp.png
b) 选中View, 单击 + 号按钮, 如下:
在弹出的窗口中,选择列表排列,选择 Image View, 然后鼠标拖动“Image View”, 移到 View Controller / View / Safe Area 下方并排的位置,如下:
c ) 选中刚刚移入的 Image View 项, 在右侧 侧窗 中 Image View / Image 中下拉选择 fp.png, 如下:
此时, 左侧Image View 名更改为 fp.png。
d) 选中 fp.png, 在图形右下角的结构按钮工具栏中,如下点击 :
勾选如下两个,添加:
则在View Controller / View 下添加了 Constraints 子项,并在子项下增长了两个约束,如下:
注意上图中右侧约束的选择;
然后, 再添加锚点定位约束,如下:
勾选 Constrain to margins, 这里,上下左右都设为1, 然后添加,如下:
注意右侧的选择,不要选择SuperView, 应该选择Safe Area;
另需注意,选择 fp.png, 在右侧侧窗的 View/ Content Mode 中, 这里选择 Aspect Fit, Semantic 为 Force Left - to - Right, 如下图所示:
可以选择下方手机栏选择不同的手机预览,看是否针对所有的手机都能正常显示。
自此, 自适应的APP 启动画面就设置好了, 重新编译即可;
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |