我有一个图像视图,如下所示:
<Image Source="{StaticResource AppIcon}" WidthRequest="80" HeightRequest="180" IsEnabled="True" ></Image>
然后,我想为Android和iOS环境声明两种不同的路径:
<ResourceDictionary>
<OnPlatform x:TypeArguments="ImageSource" x:Key="AppIcon">
<On Platform="Android" Value="/Resources/drawable/splash_logo.png" />
<On Platform="iOS" Value="????" />
</OnPlatform>
</ResourceDictionary>
问题是,我不知道如何加载我的图像从资产目录在iOS项目(Android去好).
有人能帮我吗?
1条答案
按热度按时间cigdeys31#
如果您使用的是Android的本机资源和iOS的资产目录,则仅使用文件名作为源。
例如:
原生项目中的档案路径:
使用XAML:
使用C#:
(XAML)如果Android和iOS的文件名不同,则使用OnPlatform + On标记,但值仍将仅为不带扩展名的名称。
对于C#,可以使用