0

对于圆形图像,我在我的项目中使用Xam.Plugins.Forms.ImageCircle nuget 包,它在 android 和 windows 中运行良好,但在 IOS 中显示为椭圆形,截图添加如下。

在此处输入图像描述

添加ImageCircleRenderer.Init(); AppDelegate.cs

添加了 xmlns 命名空间:

 xmlns:controls="clr-namespace:ImageCircle.Forms.Plugin.Abstractions;assembly=ImageCircle.Forms.Plugin.Abstractions"  

    <ListView x:Name="MyTweetsTopics"
                          ItemsSource="{Binding AllItems,Mode=TwoWay}"
                      IsPullToRefreshEnabled="True"
                      HasUnevenRows="True"
                       RefreshCommand="{Binding RefreshCommand}"
                       IsRefreshing="{Binding IsRefreshing}">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <ViewCell.View>
                                <StackLayout
                                HorizontalOptions="FillAndExpand"
                                VerticalOptions="FillAndExpand"
                                    Margin="5"
                                    Padding="5"
                                Orientation="Horizontal">

                                    <controls:CircleImage 
                                        HorizontalOptions="Start"
                                        VerticalOptions="Start"
                                        WidthRequest="50" 
                                        BorderColor="#1C7DB4"
                                        Aspect="AspectFill"
                                        BorderThickness="2"
                                        HeightRequest="50">
                                        <Image.Triggers>
                                            <DataTrigger TargetType="Image" Binding="{Binding isProfileImageNull}" Value="True">
                                                <Setter Property="Source" Value="dummy_profile.jpg"/>
                                            </DataTrigger>
                                            <DataTrigger TargetType="Image" Binding="{Binding isProfileImageNull}" Value="False">
                                                <Setter Property="Source" Value="{Binding thumbnailImageUrl, Converter={StaticResource urlJoinConverter}}"/>
                                            </DataTrigger>
                                        </Image.Triggers>
                                        <Image.GestureRecognizers>
                                            <TapGestureRecognizer
                                                Tapped="ShowTopicsProfile"
                                                CommandParameter="{Binding .}"
                                                NumberOfTapsRequired="1" />
                                        </Image.GestureRecognizers>
                                    </controls:CircleImage>

                                    <StackLayout
                                        HorizontalOptions="FillAndExpand"
                                        Orientation="Vertical">

                                        <StackLayout
                                            HorizontalOptions="FillAndExpand"
                                            Orientation="Horizontal">

                                            <Label 
                                        Text="{Binding pageTitle}"
                                    x:Name="pageTitle" 
                                    Font="Bold,17" 
                                    TextColor="Black"
                                    HorizontalOptions="Start" 
                                    VerticalOptions="Center"/>

                                            <StackLayout
                                                Margin="0,10,0,0"
                                        HorizontalOptions="EndAndExpand"
                                        Orientation="Horizontal"
                                        VerticalOptions="CenterAndExpand">

                                                <Image
                                        WidthRequest="20"
                                        HeightRequest="20"
                                        Margin="0,-5,0,0"
                                        VerticalOptions="Center"
                                        Source="ic_action_time.png"/>

                                                <Label 
                                        Text="{Binding pageUpdatedDate,  Converter={StaticResource cnvDateTimeConverter}}"
                                        x:Name="tweetedTime" 
                                        Font="10" 
                                        Margin="-5,-5,0,0"
                                        TextColor="Black"
                                        HorizontalOptions="FillAndExpand" 
                                        VerticalOptions="Center"/>

                                            </StackLayout>
                                        </StackLayout>

                                        <Label 
                                        Text="{Binding modifier.fullname, StringFormat='Last modified by {0:F0}'}"
                                        Font="10" 
                                        TextColor="Black"
                                        HorizontalOptions="Start" 
                                        VerticalOptions="Center"/>
                                    </StackLayout>
                                </StackLayout>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
                <ListView.Footer>
                <Label/>
                </ListView.Footer>
            </ListView>

为什么仅在 IOS 中不起作用?提前致谢

4

1 回答 1

1

您能否给我您的 xml(listview)代码,以便我能够解决您的问题,或者如果想要显示缓存中的图像,您需要使用FFImageLoading dll,它在 nuget 上可用。

class CircleImage : CachedImage
{
    public CircleImage()
    {
        LoadingPlaceholder = Glyphs.ImagePlaceholder;
        ErrorPlaceholder = Glyphs.ImagePlaceholder;
        DownsampleToViewSize = true;
        Transformations = new List<FFImageLoading.Work.ITransformation>();
        Transformations.Add(new CircleTransformation());
    }
}  

使用上述控件。

于 2018-04-27T08:03:04.380 回答