简体   繁体   English

使用故事板的 Xamarin.Forms iOS 全屏图像闪屏

[英]Xamarin.Forms iOS full screen image splash screen using storyboard

In my Xamarin Forms Application, I used Storyboard as Splash screen, In Splash screen I need to display a fullscreen image splash screen so what I do is I added a assets image and inside asset image, I added different image sizes 1x 2x 3x.在我的 Xamarin Forms 应用程序中,我使用 Storyboard 作为启动画面,在启动画面中我需要显示一个全屏图像启动画面,所以我要做的是添加一个资产图像和内部资产图像,我添加了不同的图像大小 1x 2x 3x。

Media.x 资产 and on my Storyboard, I have this setting在我的故事板上,我有这个设置

故事板 Knowing that I set different images from different sizes, I'm still having an issue when I run my app from a different device simulator.知道我设置了不同尺寸的不同图像,当我从不同的设备模拟器运行我的应用程序时仍然遇到问题。 the splash screen with a fullscreen image becomes weird.带有全屏图像的启动画面变得很奇怪。 Please see below images for the results结果请看下面的图片

模拟器 Anyone whats to share there sample solutions regarding this is much appreciated.任何人在那里分享关于此的示例解决方案都非常感谢。

By your second image, I can tell your problem is with the constraints.通过您的第二张图片,我可以看出您的问题出在约束上。 As you can see the ImageView has red lines around.如您所见,ImageView 周围有红线。 That means there are some issues with your constraints that you need to fix.这意味着您的约束存在一些需要修复的问题。 What is happening is that iOS might be having issues when rendering your page and it's doing whatever is possible.发生的情况是 iOS 在呈现您的页面时可能会遇到问题,并且它正在做任何可能的事情。

If you want to cover your whole screen (fullscreen) on the splashscreen with your image the constraints that work for me are:如果你想用你的图像在启动画面上覆盖整个屏幕(全屏),对我有用的约束是:

ImageView -> Top Space Equal 0 to SuperView    
ImageView -> Leading Space Equal 0 to SuperView    
ImageView -> Equal Height 0 to SuperView    
ImageView -> Equal Width 0 to SuperView

The above will position the image at the left and top corner and then it will match the same width and height of your SuperView.上面将把图像定位在左上角,然后它会匹配你的 SuperView 的相同宽度和高度。 That way no matter what the Superview size is the ImageView will update accordingly.这样无论 Superview 的大小是多少, ImageView都会相应地更新。

Something else to add is changing the ImageView ContentMode to AspectFill .要添加的其他内容是将ImageView ContentMode更改为AspectFill

在此处输入图片说明

Hope this helps.希望这可以帮助。

Instead of Adding image in Assets add your converted images to your resources folder.不是在 Assets 中添加图像,而是将转换后的图像添加到资源文件夹中。

For Splash Screen image adjustment follow this link https://tomsoderling.github.io/Use-all-the-space-on-iPhone-X/对于启动画面图像调整,请点击此链接https://tomsoderling.github.io/Use-all-the-space-on-iPhone-X/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM